-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from irihitech/test
Add UT for coverage.
- Loading branch information
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/AffectsPseudoClassTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
using Irihi.Avalonia.Shared.Helpers; | ||
|
||
namespace Irihi.Avalonia.Shared.UnitTest.Helpers; | ||
|
||
public class AffectsPseudoClassTests | ||
{ | ||
private class Sample : Control | ||
{ | ||
public static readonly StyledProperty<bool> TestProperty = AvaloniaProperty.Register<Sample, bool>( | ||
nameof(Test)); | ||
|
||
public bool Test | ||
{ | ||
get => GetValue(TestProperty); | ||
set => SetValue(TestProperty, value); | ||
} | ||
|
||
public static readonly RoutedEvent<RoutedEventArgs> TestChangedEvent = | ||
RoutedEvent.Register<Sample, RoutedEventArgs>(nameof(TestChanged), RoutingStrategies.Bubble); | ||
|
||
public event EventHandler<RoutedEventArgs> TestChanged | ||
{ | ||
add => AddHandler(TestChangedEvent, value); | ||
remove => RemoveHandler(TestChangedEvent, value); | ||
} | ||
|
||
static Sample() | ||
{ | ||
TestProperty.AffectsPseudoClass<Sample, RoutedEventArgs>(":test", TestChangedEvent); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestAffectsPseudoClass() | ||
{ | ||
Sample sample = new(); | ||
bool flag = false; | ||
sample.TestChanged += (_, _) => flag = true; | ||
sample.Test = true; | ||
Assert.Contains(sample.Classes, x => x == ":test"); | ||
Assert.True(flag); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters