public void CanGoBack_IsTrueIfTwoPagesNavigated() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); navigationStack.NavigateTo(new PageInfo("Page 1", null)); navigationStack.NavigateTo(new PageInfo("Page 2", null)); Assert.Equal(true, navigationStack.CanGoBack); }
public void CanGoBack_IsFalseIfTwoPageNavigatedThenBack() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); navigationStack.NavigateTo(new PageInfo("Page 1", null)); navigationStack.NavigateTo(new PageInfo("Page 2", null)); navigationStack.GoBack(); Assert.Equal(false, navigationStack.CanGoBack); }
public void GoBack_ThrowsException_SinglePageInBackStack() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); navigationStack.NavigateTo(new PageInfo("Page 1", null)); var e = Assert.Throws<InvalidOperationException>(() => navigationStack.GoBack()); Assert.Equal("You cannot navigate backwards as the back stack is empty.", e.Message); }
public void PropertyChanged_CanGoBack_IsCalledWhenSecondPageNavigated() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); navigationStack.NavigateTo(new PageInfo("Page 1", null)); int changedCount = 0; navigationStack.PropertyChanged += delegate (object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "CanGoBack") changedCount++; }; navigationStack.NavigateTo(new PageInfo("Page 2", null)); Assert.Equal(1, changedCount); }