-
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.
feat: move to shared project. add unit tests.
- Loading branch information
Showing
5 changed files
with
52 additions
and
19 deletions.
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
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
49 changes: 49 additions & 0 deletions
49
test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/LogicalHelpersTest.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,49 @@ | ||
using Avalonia.Controls; | ||
using Irihi.Avalonia.Shared.Helpers; | ||
|
||
namespace Irihi.Avalonia.Shared.UnitTest.Helpers; | ||
|
||
public class LogicalHelpersTest | ||
{ | ||
[Fact] | ||
public void CalculateDistanceFromLogicalParent_Null() | ||
{ | ||
Assert.Equal(-1, (null as Button)!.CalculateDistanceFromLogicalParent<StackPanel>()); | ||
} | ||
|
||
[Fact] | ||
public void CalculateDistanceFromLogicalParent_Default() | ||
{ | ||
var parent = new StackPanel(); | ||
var child = new Button(); | ||
parent.Children.Add(child); | ||
Assert.Equal(1, child.CalculateDistanceFromLogicalParent<StackPanel>(-1)); | ||
Assert.Equal(-1, child.CalculateDistanceFromLogicalParent<Grid>(-1)); | ||
} | ||
|
||
[Fact] | ||
public void CalculateDistanceFromLogicalParent() | ||
{ | ||
var parent = new StackPanel(); | ||
var child = new Grid(); | ||
var grandChild = new Button(); | ||
parent.Children.Add(child); | ||
child.Children.Add(grandChild); | ||
Assert.Equal(2, grandChild.CalculateDistanceFromLogicalParent<StackPanel>()); | ||
Assert.Equal(1, grandChild.CalculateDistanceFromLogicalParent<Grid>()); | ||
Assert.Equal(-1, grandChild.CalculateDistanceFromLogicalParent<Canvas>()); | ||
} | ||
|
||
[Fact] | ||
public void CalculateDistanceFromLogicalParent_Self() | ||
{ | ||
var parent = new StackPanel(); | ||
var child = new Grid(); | ||
var grandChild = new Button(); | ||
parent.Children.Add(child); | ||
child.Children.Add(grandChild); | ||
Assert.Equal(2, grandChild.CalculateDistanceFromLogicalParent<StackPanel>()); | ||
Assert.Equal(1, grandChild.CalculateDistanceFromLogicalParent<Grid>()); | ||
Assert.Equal(0, grandChild.CalculateDistanceFromLogicalParent<Button>()); | ||
} | ||
} |
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
18 changes: 0 additions & 18 deletions
18
test/Irihi.Avalonia.Shared.UnitTest/Helpers/LogicalHelpersTest.cs
This file was deleted.
Oops, something went wrong.