-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: adding tests for WindowManagerExtensions
- Loading branch information
Showing
2 changed files
with
38 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
37 changes: 37 additions & 0 deletions
37
tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/WindowManagerTests.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,37 @@ | ||
| ||
using Prism.Navigation.Xaml; | ||
|
||
namespace Prism.DryIoc.Maui.Tests.Fixtures.Navigation; | ||
|
||
public class WindowManagerTests : TestBase | ||
{ | ||
public WindowManagerTests(ITestOutputHelper testOutputHelper) | ||
: base(testOutputHelper) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[InlineData("NavigationPage/MockViewA/MockViewB/MockViewC")] | ||
[InlineData("MockHome/NavigationPage/MockViewA")] | ||
public void WindowManagerGetsNavigationServiceFromCurrentPage(string uri) | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow(uri)) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
var rootPage = window.Page; | ||
var currentPage = rootPage; | ||
if (rootPage is NavigationPage navigationPage) | ||
{ | ||
currentPage = navigationPage.CurrentPage; | ||
} | ||
if (rootPage is FlyoutPage flyoutPage && flyoutPage.Detail is NavigationPage detailPage) | ||
{ | ||
currentPage = detailPage.CurrentPage; | ||
} | ||
|
||
var currentNavigationService = Prism.Navigation.Xaml.Navigation.GetNavigationService(currentPage); | ||
var windowManager = rootPage.GetContainerProvider().Resolve<IWindowManager>(); | ||
Assert.Same(currentNavigationService, windowManager.GetCurrentNavigationService()); | ||
} | ||
} |