< Summary

Information
Class: LOCKnet.App.Converters.StringToMaterialIconKindConverter
Assembly: LOCKnet.App
File(s): /home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/Converters/StringToMaterialIconKindConverter.cs
Line coverage
86%
Covered lines: 13
Uncovered lines: 2
Coverable lines: 15
Total lines: 31
Line coverage: 86.6%
Branch coverage
45%
Covered branches: 10
Total branches: 22
Branch coverage: 45.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()50%22100%
Convert(...)43.75%191677.77%
ConvertBack(...)50%44100%

File(s)

/home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/Converters/StringToMaterialIconKindConverter.cs

#LineLine coverage
 1using Avalonia.Data.Converters;
 2using System.Globalization;
 3
 4namespace LOCKnet.App.Converters;
 5
 6public sealed class StringToMaterialIconKindConverter : IValueConverter
 7{
 18  private static readonly Type? MaterialIconKindType =
 19    Type.GetType("Material.Icons.MaterialIconKind, Material.Icons") ??
 110    Type.GetType("Material.Icons.MaterialIconKind, Material.Icons.Avalonia");
 11
 12  public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
 313  {
 314    if (MaterialIconKindType is null)
 015    {
 016      return value?.ToString() ?? string.Empty;
 17    }
 18
 319    if (value is string text && Enum.TryParse(MaterialIconKindType, text, out var parsedKind))
 120    {
 121      return parsedKind;
 22    }
 23
 224    return Enum.GetValues(MaterialIconKindType).GetValue(0) ?? value?.ToString() ?? string.Empty;
 325  }
 26
 27  public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
 128  {
 129    return value?.ToString() ?? string.Empty;
 130  }
 31}