-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
Navigation.SetPageType
method, and add support for generic type…
… pages
- Loading branch information
1 parent
2e10359
commit 654f014
Showing
3 changed files
with
69 additions
and
2 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
52 changes: 52 additions & 0 deletions
52
Tests/Nalu.Maui.Test/Navigation/NavigationSegmentAttributeTests.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,52 @@ | ||
namespace Nalu.Maui.Test.Navigation; | ||
|
||
public class NavigationSegmentAttributeTests | ||
{ | ||
[NavigationSegment("Hello")] | ||
private class WithAttribute; | ||
|
||
private class WithoutAttribute; | ||
|
||
private class WithGenericAttribute<T>; | ||
|
||
[Fact(DisplayName = "NavigationSegmentAttribute.GetSegmentName, when no attribute, returns type name")] | ||
public void NavigationSegmentAttributeGetSegmentNameWhenNoAttributeReturnsTypeName() | ||
{ | ||
// Arrange | ||
var type = typeof(WithoutAttribute); | ||
|
||
// Act | ||
var result = NavigationSegmentAttribute.GetSegmentName(type); | ||
|
||
// Assert | ||
result.Should().Be(nameof(WithoutAttribute)); | ||
} | ||
|
||
[Fact(DisplayName = "NavigationSegmentAttribute.GetSegmentName, when attribute, returns attribute value")] | ||
public void NavigationSegmentAttributeGetSegmentNameWhenAttributeReturnsAttributeValue() | ||
{ | ||
// Arrange | ||
var type = typeof(WithAttribute); | ||
|
||
// Act | ||
var result = NavigationSegmentAttribute.GetSegmentName(type); | ||
|
||
// Assert | ||
result.Should().Be("Hello"); | ||
} | ||
|
||
[Fact(DisplayName = "NavigationSegmentAttribute.GetSegmentName, when generic type, returns type name")] | ||
public void NavigationSegmentAttributeGetSegmentNameWhenGenericTypeReturnsTypeName() | ||
{ | ||
// Arrange | ||
var type = typeof(WithGenericAttribute<WithoutAttribute>); | ||
|
||
// Act | ||
var result = NavigationSegmentAttribute.GetSegmentName(type); | ||
var uri = new Uri($"//{result}"); | ||
|
||
// Assert | ||
result.Should().Be("WithGenericAttribute-WithoutAttribute"); | ||
uri.IsAbsoluteUri.Should().BeTrue(); | ||
} | ||
} |