added tests to project
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using CursorLang.Models;
|
||||
using CursorLang.ViewModels;
|
||||
|
||||
namespace CursorLang.Tests.ViewModels;
|
||||
|
||||
public sealed class EnumOptionTests
|
||||
{
|
||||
[Fact]
|
||||
public void An_option_remembers_its_value_and_caption()
|
||||
{
|
||||
var option = new EnumOption<AppTheme>(AppTheme.Dark, "Dark theme");
|
||||
|
||||
Assert.Equal(AppTheme.Dark, option.Value);
|
||||
Assert.Equal("Dark theme", option.Display);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_changed_caption_is_announced_to_subscribers()
|
||||
{
|
||||
var option = new EnumOption<AppTheme>(AppTheme.Dark, "Dark");
|
||||
List<string?> changed = [];
|
||||
option.PropertyChanged += (_, e) => changed.Add(e.PropertyName);
|
||||
|
||||
option.Display = "Dark theme";
|
||||
|
||||
Assert.Equal("Dark theme", option.Display);
|
||||
Assert.Equal([nameof(EnumOption<>.Display)], changed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_same_caption_is_not_announced_again()
|
||||
{
|
||||
var option = new EnumOption<AppTheme>(AppTheme.Dark, "Dark theme");
|
||||
List<string?> changed = [];
|
||||
option.PropertyChanged += (_, e) => changed.Add(e.PropertyName);
|
||||
|
||||
option.Display = "Dark theme";
|
||||
|
||||
Assert.Empty(changed);
|
||||
}
|
||||
|
||||
// Accessibility tools take the name of a list item from here
|
||||
[Fact]
|
||||
public void An_option_presents_itself_by_its_caption()
|
||||
{
|
||||
Assert.Equal("Dark theme", new EnumOption<AppTheme>(AppTheme.Dark, "Dark theme").ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_changed_caption_changes_the_presentation_too()
|
||||
{
|
||||
var option = new EnumOption<ScreenPosition>(ScreenPosition.Center, "Center") { Display = "In the centre" };
|
||||
|
||||
Assert.Equal("In the centre", option.ToString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user