public void GoBack_ThrowsException_NoPageInBackStack() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); var e = Assert.Throws<InvalidOperationException>(() => navigationStack.GoBack()); Assert.Equal("You cannot navigate backwards as the back stack is empty.", e.Message); }
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 PropertyChanged_CanGoBack_IsCalledWhenSecondPageNavigatedThenBack() { NavigationStackWithHome navigationStack = new NavigationStackWithHome(); navigationStack.NavigateTo(new PageInfo("Page 1", null)); navigationStack.NavigateTo(new PageInfo("Page 2", null)); int changedCount = 0; navigationStack.PropertyChanged += delegate (object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "CanGoBack") changedCount++; }; navigationStack.GoBack(); Assert.Equal(1, changedCount); }