public void NavigateTo_WithPageName_NavigatesToPage() { MockNavigationStack navigationStack = new MockNavigationStack(); navigationStack.NavigateTo("Page 1"); Assert.Equal(new string[] { "Page 1" }, navigationStack.Select(e => e.PageName).ToList()); Assert.Equal(new object[] { null }, navigationStack.Select(e => e.GetArguments<string>()).ToList()); }
public void GoBackTo_NavigatesBackToPage() { MockNavigationStack navigationStack = new MockNavigationStack(); navigationStack.NavigateTo("Page 1"); navigationStack.NavigateTo("Page 2"); navigationStack.NavigateTo("Page 3"); navigationStack.NavigateTo("Page 4"); navigationStack.GoBackTo("Page 2"); Assert.Equal(new string[] { "Page 1", "Page 2" }, navigationStack.Select(e => e.PageName).ToList()); }
public async Task RestoreNavigationStack_NavigatesToHomePageIfNoPreviousNavigationStack() { MockNavigationStack navigationStack = new MockNavigationStack(); INavigationManager navigationManager = CreateNavigationManager(navigationStack: navigationStack); navigationManager.NavigationStorageType = NavigationStorageType.Local; bool success = await navigationManager.RestoreNavigationStack(); Assert.Equal(false, success); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { "Home" }, pageNames); }
public async Task RestoreNavigationStack_NavigatesToHomePageIfStateFileIsCorrupt() { MockNavigationStack navigationStack = new MockNavigationStack(); MockStorageManager storageManager = new MockStorageManager(); INavigationManager navigationManager = CreateNavigationManager(navigationStack: navigationStack, storageManager: storageManager); navigationManager.NavigationStorageType = NavigationStorageType.Local; InvalidNavigationState state = new InvalidNavigationState(); await storageManager.StoreAsync <InvalidNavigationState>(ApplicationData.Current.LocalFolder, "Okra_Navigation_NavigationManager.xml", state); bool success = await navigationManager.RestoreNavigationStack(); Assert.Equal(false, success); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { "Home" }, pageNames); }
public async Task RestoreNavigationStack_RestoresPreviousNavigationStackViaRoamingStorage() { IStorageManager storageManager = new MockStorageManager(); // --- First Instance --- { MockNavigationStack navigationStack = new MockNavigationStack(); MockLifetimeManager lifetimeManager = new MockLifetimeManager(); INavigationManager navigationManager = CreateNavigationManager(navigationStack: navigationStack, lifetimeManager: lifetimeManager, storageManager: storageManager); navigationManager.NavigationStorageType = NavigationStorageType.Roaming; // Navigate to some pages navigationStack.Add(new PageInfo("Page 1", null)); navigationStack.Add(new PageInfo("Page 2", null)); // Suspend the application lifetimeManager.Suspend(); } // --- Second Instance --- { MockNavigationStack navigationStack = new MockNavigationStack(); INavigationManager navigationManager = CreateNavigationManager(navigationStack: navigationStack, storageManager: storageManager); navigationManager.NavigationStorageType = NavigationStorageType.Roaming; // Restore the navigation stack bool success = await navigationManager.RestoreNavigationStack(); // Assert that the current page is restored from storage Assert.Equal(true, success); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { "Page 1", "Page 2" }, pageNames); } }
public void SettingsPaneBackClick_GoesBackInNavigationStack() { MockNavigationStack navigationStack = new MockNavigationStack(); TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(navigationStack: navigationStack); navigationStack.NavigateTo(new PageInfo("Page 1", null)); navigationStack.NavigateTo(new PageInfo("Page 2", null)); BackClickEventArgs e = new BackClickEventArgs() { Handled = false }; settingsPaneManager.CallOnSettingsPaneBackClick(e); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { "Page 1" }, pageNames); }
public void FlyoutClosed_ClearsNavigationStack() { MockNavigationStack navigationStack = new MockNavigationStack(); TestableSettingsPaneManager settingsPaneManager = CreateSettingsPaneManager(navigationStack: navigationStack); navigationStack.NavigateTo(new PageInfo("Page 1", null)); navigationStack.NavigateTo(new PageInfo("Page 2", null)); settingsPaneManager.CallOnSettingsFlyoutClosed(); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { }, pageNames); }
public void NavigateTo_WithTypeAndParameter_NavigatesToPageWithFullTypeName() { MockNavigationStack navigationStack = new MockNavigationStack(); navigationStack.NavigateTo(typeof(MockNavigationBase.MockPage), "Parameter 1"); Assert.Equal(new string[] { MockNavigationBase.MOCKPAGE_NAME }, navigationStack.Select(e => e.PageName).ToList()); Assert.Equal(new object[] { "Parameter 1" }, navigationStack.Select(e => e.GetArguments<string>()).ToList()); }
public async Task RestoreNavigationStack_NavigatesToHomePageIfStateFileIsCorrupt() { MockNavigationStack navigationStack = new MockNavigationStack(); MockStorageManager storageManager = new MockStorageManager(); INavigationManager navigationManager = CreateNavigationManager(navigationStack: navigationStack, storageManager: storageManager); navigationManager.NavigationStorageType = NavigationStorageType.Local; InvalidNavigationState state = new InvalidNavigationState(); await storageManager.StoreAsync<InvalidNavigationState>(ApplicationData.Current.LocalFolder, "Okra_Navigation_NavigationManager.xml", state); bool success = await navigationManager.RestoreNavigationStack(); Assert.Equal(false, success); string[] pageNames = navigationStack.Select(page => page.PageName).ToArray(); Assert.Equal(new string[] { "Home" }, pageNames); }