Skip to content

Commit

Permalink
Modify UnitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
niimima committed Jul 29, 2024
1 parent e1a4cf5 commit b1dcfc2
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,28 +544,21 @@ public async Task Navigation_FromRootNavigationPageUsingRoute()
}

[Fact]
public async Task Navigation_FromIntermediatePageUsingRoute()
public async Task Navigation_FromFlyoutPageUsingRoute()
{
var mauiApp = CreateBuilder(prism => prism.CreateWindow("MockHome/NavigationPage/MockViewA"))
.Build();
var window = GetWindow(mauiApp);

var mockHome = (MockHome)window.Page;
var pageNavigatingFrom = (NavigationPage)mockHome.Detail;
Assert.IsType<MockViewA>(pageNavigatingFrom.CurrentPage);
var mockHome = (FlyoutPage)window.Page;
var navigationPage = (NavigationPage)mockHome.Detail;
Assert.IsType<MockViewA>(navigationPage.CurrentPage);

var result = await pageNavigatingFrom.CurrentPage.GetContainerProvider()
.Resolve<INavigationService>()
.NavigateFromAsync("NavigationPage", UriParsingHelper.Parse("MockViewB"), null);
var navigationService = Prism.Navigation.Xaml.Navigation.GetNavigationService(window.CurrentPage);
var result = await navigationService.NavigateFromAsync("MockHome", UriParsingHelper.Parse("MockViewB"), null);

Assert.True(result.Success);

// NavigationPage has not been replaced.
var pageNavigatedFrom = (NavigationPage)mockHome.Detail;
Assert.Equal(pageNavigatingFrom, pageNavigatedFrom);

// Navigation should be succeeded.
Assert.IsType<MockViewB>(pageNavigatedFrom.CurrentPage);
Assert.IsType<MockViewB>(mockHome.Detail);
}

[Theory]
Expand Down

0 comments on commit b1dcfc2

Please sign in to comment.