< Summary

Information
Class: LOCKnet.App.ViewModels.LockScreenViewModel
Assembly: LOCKnet.App
File(s): /home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/ViewModels/LockScreenViewModel.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 38
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Unlock(...)83.33%66100%

File(s)

/home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/ViewModels/LockScreenViewModel.cs

#LineLine coverage
 1using CommunityToolkit.Mvvm.ComponentModel;
 2using System.Security;
 3
 4namespace LOCKnet.App.ViewModels;
 5
 6/// <summary>
 7/// Wird angezeigt, wenn die Sitzung durch Auto-Lock oder manuell gesperrt wurde.
 8/// </summary>
 9public partial class LockScreenViewModel : ViewModelBase
 10{
 11  public event EventHandler? UnlockSucceeded;
 12
 13  [ObservableProperty]
 314  private string _errorMessage = string.Empty;
 15
 16  public void Unlock(SecureString password)
 417  {
 418    ArgumentNullException.ThrowIfNull(password);
 419    ErrorMessage = string.Empty;
 20    try
 421    {
 422      var unlock = AppServices.Current.MasterKeyManager.Unlock(password);
 323      if (unlock is null)
 124      {
 125        ErrorMessage = "Falsches Passwort.";
 126        return;
 27      }
 28
 229      AppServices.Current.SessionManager.Open(unlock.VaultKey);
 230      AppServices.Current.ActivityMonitor.Start();
 231      UnlockSucceeded?.Invoke(this, EventArgs.Empty);
 232    }
 133    catch (Exception ex)
 134    {
 135      ErrorMessage = ex is InvalidOperationException ? ex.Message : "Entsperren fehlgeschlagen.";
 136    }
 437  }
 38}