< Summary

Line coverage
98%
Covered lines: 56
Uncovered lines: 1
Coverable lines: 57
Total lines: 126
Line coverage: 98.2%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: !XamlIlPopulate(...)100%22100%
File 2: .ctor()100%11100%
File 2: OnUnlockClick(...)100%4490%
File 2: CreateSecureString(...)100%44100%

File(s)

/home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/Views/LockScreenView.axaml

#LineLine coverage
 41<UserControl xmlns="https://github.com/avaloniaui"
 2             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 3             xmlns:vm="using:LOCKnet.App.ViewModels"
 4             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6             mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="600"
 7             x:Class="LOCKnet.App.Views.LockScreenView"
 8             x:DataType="vm:LockScreenViewModel"
 29             Background="{StaticResource BrushBg}">
 10
 11    <Design.DataContext>
 12        <vm:LockScreenViewModel/>
 13    </Design.DataContext>
 14
 415    <Grid RowDefinitions="*,Auto,*">
 816        <StackPanel Grid.Row="1"
 17                    Width="380"
 218                    HorizontalAlignment="Center"
 19                    Spacing="0">
 20
 21            <!-- Lock Icon -->
 822            <Border Width="80" Height="80"
 223                    CornerRadius="40"
 224                    Background="{StaticResource BrushSurface}"
 25                    HorizontalAlignment="Center"
 226                    Margin="0,0,0,12">
 827                <TextBlock Text="■"
 28                           FontSize="28"
 229                           Foreground="{StaticResource BrushAccent}"
 30                           HorizontalAlignment="Center"
 231                           VerticalAlignment="Center"/>
 32            </Border>
 33
 34            <!-- Title -->
 835            <TextBlock Text="Sitzung gesperrt"
 36                       FontSize="26"
 237                       FontWeight="Bold"
 238                       Foreground="{StaticResource BrushTextPrimary}"
 39                       HorizontalAlignment="Center"
 240                       Margin="0,0,0,6"/>
 41
 42            <!-- Subtitle -->
 1043            <TextBlock Text="Gib dein Master-Passwort ein, um fortzufahren."
 44                       FontSize="14"
 245                       Foreground="{StaticResource BrushTextSecondary}"
 46                       HorizontalAlignment="Center"
 247                       TextAlignment="Center"
 48                       Margin="0,0,0,40"/>
 49
 50            <!-- Card -->
 651            <Border Background="{StaticResource BrushSurface}"
 252                    CornerRadius="{StaticResource RadiusLg}"
 53                    Padding="40,36">
 654                <StackPanel Spacing="20">
 55
 56                    <!-- Password -->
 657                    <StackPanel Spacing="6">
 658                        <TextBlock Text="Master-Passwort"
 59                                   FontSize="12"
 260                                   Foreground="{StaticResource BrushTextSecondary}"/>
 661                        <TextBox x:Name="PasswordInput"
 62                                 PasswordChar="●"
 263                                 Watermark="Passwort eingeben…"/>
 64                    </StackPanel>
 65
 66                    <!-- Error -->
 667                    <TextBlock Text="{Binding ErrorMessage}"
 268                               Foreground="{StaticResource BrushError}"
 69                               FontSize="12"
 270                               IsVisible="{Binding ErrorMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}
 71
 72                    <!-- Unlock Button -->
 873                    <Button Content="Entsperren"
 74                            Classes="primary"
 275                            Click="OnUnlockClick"
 76                            HorizontalAlignment="Stretch"
 277                            HorizontalContentAlignment="Center"/>
 78
 79                </StackPanel>
 80            </Border>
 81
 82        </StackPanel>
 83    </Grid>
 84
 85</UserControl>

/home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/Views/LockScreenView.axaml.cs

#LineLine coverage
 1using Avalonia.Controls;
 2using Avalonia.Interactivity;
 3using LOCKnet.App.ViewModels;
 4using System.Security;
 5
 6namespace LOCKnet.App.Views;
 7
 8public partial class LockScreenView : UserControl
 9{
 210  public LockScreenView()
 211  {
 212    InitializeComponent();
 213  }
 14
 15  private void OnUnlockClick(object? sender, RoutedEventArgs e)
 216  {
 217    if (DataContext is not LockScreenViewModel vm)
 118      return;
 19
 120    var passwordInput = this.FindControl<TextBox>("PasswordInput");
 121    if (passwordInput is null)
 022      return;
 23
 124    using var password = CreateSecureString(passwordInput.Text);
 125    vm.Unlock(password);
 126    passwordInput.Text = string.Empty;
 327  }
 28
 29  private static SecureString CreateSecureString(string? value)
 130  {
 131    var secure = new SecureString();
 132    if (!string.IsNullOrEmpty(value))
 133    {
 4334      foreach (var c in value)
 2035        secure.AppendChar(c);
 136    }
 37
 138    secure.MakeReadOnly();
 139    return secure;
 140  }
 41}