Skip to content

Commit

Permalink
fix tests and more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
snixtho committed Dec 6, 2023
1 parent d080544 commit ea17bc1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 50 deletions.
51 changes: 50 additions & 1 deletion src/EvoSC.Manialinks/Util/FontManialinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,42 @@ public class FontManialinkHelper
{
private readonly dynamic _theme;

/// <summary>
/// Thin thickness of the current font.
/// </summary>
public string Thin => ToThin(_theme.UI_Font);

/// <summary>
/// Regular thickness of the current font.
/// </summary>
public string Regular => ToRegular(_theme.UI_Font);

/// <summary>
/// Bold thickness of the current font.
/// </summary>
public string Bold => ToBold(_theme.UI_Font);

/// <summary>
/// Extra bold thickness of the current font.
/// </summary>
public string ExtraBold => ToExtraBold(_theme.UI_Font);

/// <summary>
/// Mono version of the current font.
/// </summary>
public string Mono => ToExtraBold(_theme.UI_Font);

public FontManialinkHelper(IThemeManager theme)
{
_theme = theme.Theme;
}

/// <summary>
/// Convert the provided font to it's regular thickness version.
/// </summary>
/// <param name="font">Font to convert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public string ToRegular(string font) => font switch
{
_ when font.StartsWith("GameFont") => "GameFontSemiBold",
Expand All @@ -26,25 +51,49 @@ _ when font.StartsWith("Roboto") => "RobotoCondensed",
_ => throw new InvalidOperationException("Invalid font.")
};

/// <summary>
/// Convert the provided font to it's thin thickness version.
/// </summary>
/// <param name="font">Font to convert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public string ToThin(string font) => font switch
{
_ when font.StartsWith("GameFont") => "GameFontSemiRegular",
_ => ToRegular(font)
};

/// <summary>
/// Convert the provided font to it's bold thickness version.
/// </summary>
/// <param name="font">Font to convert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public string ToBold(string font) => font switch
{
_ when font.StartsWith("GameFont") => "GameFontExtraBold",
_ when font.StartsWith("Roboto") => "RobotoCondensedBold",
_ => ToRegular(font)
};

/// <summary>
/// Convert the provided font to it's extra bold thickness version.
/// </summary>
/// <param name="font">Font to convert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public string ToExtraBold(string font) => font switch
{
_ when font.StartsWith("GameFont") => "GameFontBlack",
_ => ToBold(font)
};


/// <summary>
/// Convert the provided font to it's mono version.
/// </summary>
/// <param name="font">Font to convert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public string ToMono(string font) => font switch
{
_ when font.StartsWith("Rajdhani") => "RajdhaniMono",
Expand Down
10 changes: 10 additions & 0 deletions src/EvoSC.Manialinks/Util/GlobalManialinkUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public GlobalManialinkUtils(IThemeManager themeManager)
_theme = themeManager.Theme;
}

/// <summary>
/// Status type to a color.
/// </summary>
/// <param name="type">Name of the status.</param>
/// <returns></returns>
public string TypeToColorBg(string type) => type.ToLower() switch
{
"info" => _theme.Teal,
Expand All @@ -23,6 +28,11 @@ public GlobalManialinkUtils(IThemeManager themeManager)
_ => _theme.UI_BgPrimary
};

/// <summary>
/// Status type to an icon.
/// </summary>
/// <param name="type">Name of the status.</param>
/// <returns></returns>
public string TypeToIcon(string type) => type.ToLower() switch
{
"info" => _icons.InfoCircle,
Expand Down
2 changes: 1 addition & 1 deletion tests/EvoSC.Common.Tests/Themes/ThemeManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public async Task Available_Themes_Property_Returns_All_Themes()
var themes = mock.ThemeManager.AvailableThemes.Select(t => t.Name).ToArray();

Assert.NotEmpty(themes);
Assert.Equal(new[]{"Default", "MyTheme", "MyTheme2", "MyTheme3"}, themes);
Assert.Equal(new[]{"MyTheme", "MyTheme2", "MyTheme3"}, themes);
Assert.Equal("MyThemeOptionValue", mock.ThemeManager.Theme.MyThemeOption);
Assert.Equal("MyThemeOptionValue2", mock.ThemeManager.Theme.MyThemeOption2);
Assert.Equal("MyThemeOptionValue3", mock.ThemeManager.Theme.MyThemeOption3);
Expand Down
45 changes: 0 additions & 45 deletions tests/Modules/FastestCp.Tests/FastestCpManialinkTest.cs

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Modules/FastestCp.Tests/FastestCpServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ await _fastestCpService.RegisterCpTimeAsync(new WayPointEventArgs

var actualData = new List<object>();
_manialinkManagerMock.Verify(
manager => manager.SendPersistentManialinkAsync("FastestCpModule.FastestCpModule", Capture.In(actualData)), Times.Once);
manager => manager.SendPersistentManialinkAsync("FastestCpModule.FastestCp", Capture.In(actualData)), Times.Once);
Assert.NotEmpty(actualData);
Assert.Equivalent(
new { times = new List<PlayerCpTime?> { new("NickName1", 0, TimeSpan.FromMilliseconds(10)) } },
Expand Down Expand Up @@ -87,7 +87,7 @@ await _fastestCpService.RegisterCpTimeAsync(new WayPointEventArgs
});

_manialinkManagerMock.Verify(
manager => manager.SendPersistentManialinkAsync("FastestCpModule.FastestCpModule", It.IsAny<object>()), Times.Never);
manager => manager.SendPersistentManialinkAsync("FastestCpModule.FastestCp", It.IsAny<object>()), Times.Never);
}

[Fact]
Expand All @@ -102,7 +102,7 @@ public async void Should_Reset_Store()
var after = fieldInfo?.GetValue(_fastestCpService);


_manialinkManagerMock.Verify(manager => manager.HideManialinkAsync("FastestCpModule.FastestCpModule"), Times.Once);
_manialinkManagerMock.Verify(manager => manager.HideManialinkAsync("FastestCpModule.FastestCp"), Times.Once);

Assert.NotNull(before);
Assert.NotNull(after);
Expand Down

0 comments on commit ea17bc1

Please sign in to comment.