public async Task MultiplePopsRemoveMiddlePagesBeforeFinalPopWhenUsingModal() { Routing.RegisterRoute("ModalTestPage", typeof(ShellModalTests.ModalTestPage)); TestShell testShell = new TestShell( CreateShellSection <NavigationMonitoringTab>(shellContentRoute: "rootpage") ); var pageLeftOnStack = new ContentPage(); var middlePage = new ContentPage(); var tab = (NavigationMonitoringTab)testShell.CurrentItem.CurrentItem; await testShell.Navigation.PushAsync(pageLeftOnStack); await testShell.Navigation.PushAsync(middlePage); await testShell.GoToAsync("ModalTestPage"); tab.NavigationsFired.Clear(); await testShell.GoToAsync("../.."); Assert.That(testShell.CurrentState.Location.ToString(), Is.EqualTo($"//rootpage/{Routing.GetRoute(pageLeftOnStack)}")); Assert.AreEqual("OnRemovePage", tab.NavigationsFired[0]); Assert.AreEqual("OnPopModal", tab.NavigationsFired[1]); Assert.AreEqual(2, tab.NavigationsFired.Count); }
public async Task NavigationPushAndPopBasic() { var flyoutItem = CreateShellItem <FlyoutItem>( shellItemRoute: "item", shellSectionRoute: "section", shellContentRoute: "content" ); var itemRoute = "item/section/content"; var page1 = new ContentPage(); var page2 = new ContentPage(); var shell = new TestShell(flyoutItem); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}")); await shell.Navigation.PushAsync(page1); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}")); await shell.Navigation.PushAsync(page2); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}/{Routing.GetRoute(page2)}")); await shell.Navigation.PopAsync(); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}")); }
public async Task DotDotNavigateBackFromPagesWithDefaultRoute() { var flyoutItem = CreateShellItem <FlyoutItem>(); var itemRoute = Routing.GetRoute(flyoutItem.CurrentItem.CurrentItem); var page1 = new ContentPage(); var page2 = new ContentPage(); TestShell shell = new TestShell() { Items = { flyoutItem } }; Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}")); await shell.Navigation.PushAsync(page1); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}")); await shell.Navigation.PushAsync(page2); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}/{Routing.GetRoute(page2)}")); await shell.GoToAsync(".."); Assert.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{itemRoute}/{Routing.GetRoute(page1)}")); }
public async Task CaseIgnoreRouting() { var routes = new[] { "Tab1", "TAB2", "@-_-@", "+:~", "=%", "Super_Simple+-Route.doc", "1/2", @"1\2/3", "app://tab" }; var services = Substitute.For <IServiceProvider>(); foreach (var route in routes) { var formattedRoute = Routing.FormatRoute(route); Routing.RegisterRoute(formattedRoute, typeof(ShellItem)); var content1 = Routing.GetOrCreateContent(formattedRoute, services); Assert.IsNotNull(content1); Assert.AreEqual(Routing.GetRoute(content1), formattedRoute); } Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute("app://IMPL_tab21", typeof(ShellItem))); Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute(@"app:\\IMPL_tab21", typeof(ShellItem))); Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute(string.Empty, typeof(ShellItem))); Assert.Catch(typeof(ArgumentNullException), () => Routing.RegisterRoute(null, typeof(ShellItem))); Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute("tab1/IMPL_tab11", typeof(ShellItem))); Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute("IMPL_shell", typeof(ShellItem))); Assert.Catch(typeof(ArgumentException), () => Routing.RegisterRoute("app://tab2/IMPL_tab21", typeof(ShellItem))); }
public async Task NavigateToDefaultShellContent() { TestShell testShell = new TestShell(CreateShellItem<FlyoutItem>()); var page = new ContentPage(); var contentRoute = testShell.CurrentItem.CurrentItem.CurrentItem.Route; var pageRoute = Routing.GetRoute(page); await testShell.Navigation.PushAsync(new ContentPage()); await testShell.Navigation.PushAsync(page); await testShell.GoToAsync($"//{contentRoute}/{pageRoute}"); Assert.That(testShell.CurrentState.Location.ToString(), Is.EqualTo($"//{contentRoute}/{pageRoute}")); }
public async Task DefaultRoutesMaintainedIfThatsAllThereIs() { Routing.RegisterRoute(nameof(DefaultRoutesMaintainedIfThatsAllThereIs), typeof(ContentPage)); var shell = new Shell(); var shellContent = new ShellContent(); FlyoutItem flyoutItem = new FlyoutItem() { Items = { shellContent } }; shell.Items.Add(flyoutItem); await shell.GoToAsync(nameof(DefaultRoutesMaintainedIfThatsAllThereIs)); Assume.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{Routing.GetRoute(shellContent)}/{nameof(DefaultRoutesMaintainedIfThatsAllThereIs)}")); await shell.GoToAsync(".."); }