Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Fix additional scenarios with nested defined routes #13648

Merged
merged 5 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion Xamarin.Forms.Core.UnitTests/ShellNavigatingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ public async Task GoBackFromRouteWithMultiplePaths()
await shell.Navigation.PopAsync();
}


[Test]
public async Task GoBackFromRouteWithMultiplePathsHierarchical()
{
Expand All @@ -933,6 +932,70 @@ public async Task GoBackFromRouteWithMultiplePathsHierarchical()
await shell.Navigation.PopAsync();
}

[Test]
public async Task HierarchicalNavigation()
{
Routing.RegisterRoute("page1/page2", typeof(ShellTestPage));
var shell = new TestShell(
CreateShellItem(shellSectionRoute: "page1")
);

await shell.GoToAsync($"page1/page2?{nameof(ShellTestPage.SomeQueryParameter)}=1");

Assert.AreEqual("1", ((ShellTestPage)shell.CurrentPage).SomeQueryParameter);
}

[Test]
public async Task HierarchicalNavigationMultipleRoutes()
{
Routing.RegisterRoute("page1/page2", typeof(ShellTestPage));
Routing.RegisterRoute("page1/page2/page3", typeof(TestPage1));
var shell = new TestShell(
CreateShellItem(shellSectionRoute: "page1")
);

await shell.GoToAsync($"page1/page2?{nameof(ShellTestPage.SomeQueryParameter)}=1");

Assert.AreEqual("1", ((ShellTestPage)shell.CurrentPage).SomeQueryParameter);
await shell.GoToAsync($"page1/page2/page3");

Assert.IsTrue(shell.CurrentPage is TestPage1);
Assert.IsTrue(shell.Navigation.NavigationStack[1] is ShellTestPage);
}

[Test]
public async Task HierarchicalNavigationMultipleRoutesVariation1()
{
Routing.RegisterRoute("page1/page2", typeof(ShellTestPage));
Routing.RegisterRoute("page1/page2/page3", typeof(TestPage1));
var shell = new TestShell(
CreateShellItem(shellSectionRoute: "page1")
);

await shell.GoToAsync($"page1/page2/page3");

Assert.IsTrue(shell.CurrentPage is TestPage1);
Assert.IsTrue(shell.Navigation.NavigationStack[1] is ShellTestPage);
}

[Test]
public async Task HierarchicalNavigationWithBackNavigation()
{
Routing.RegisterRoute("page1/page2", typeof(ShellTestPage));
Routing.RegisterRoute("page1/page2/page3", typeof(TestPage1));
var shell = new TestShell(
CreateShellItem(shellSectionRoute: "page1")
);

await shell.GoToAsync($"page1/page2");
await shell.GoToAsync($"page1/page2/page3");
Assert.IsTrue(shell.CurrentPage is TestPage1);
await shell.GoToAsync($"..");
Assert.IsTrue(shell.Navigation.NavigationStack[1] is ShellTestPage);
PureWeen marked this conversation as resolved.
Show resolved Hide resolved
await shell.GoToAsync($"..");

}

public class NavigationMonitoringTab : Tab
{
public List<string> NavigationsFired = new List<string>();
Expand Down
Loading