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 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 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 SettingsPaneBackClick_HandlesEvent()
        {
            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);

            Assert.Equal(true, e.Handled);
        }
        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_WithPageName_Exception_IfPageNameIsNull()
        {
            MockNavigationStack navigationStack = new MockNavigationStack();

            var e = Assert.Throws<ArgumentException>(() => navigationStack.NavigateTo((string)null));

            Assert.Equal("The argument cannot be null or an empty string.\r\nParameter name: pageName", e.Message);
            Assert.Equal("pageName", e.ParamName);
        }
        public void NavigateTo_WithTypeAndParameter_Exception_IfPageNameIsNull()
        {
            MockNavigationStack navigationStack = new MockNavigationStack();

            var e = Assert.Throws<ArgumentNullException>(() => navigationStack.NavigateTo((Type)null, "Parameter"));

            Assert.Equal("Value cannot be null.\r\nParameter name: pageName", e.Message);
            Assert.Equal("pageName", e.ParamName);
        }
        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());
        }