public void BackCommandShouldBeEnabledOnNavigatingToSecondPage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); Assert.True(target.NavigateBack.CanExecute(null)); Assert.False(target.NavigateForward.CanExecute(null)); }
public void ShouldCallDeactivatedOnOldPage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); first.ClearReceivedCalls(); target.NavigateTo(second); first.Received(1).Deactivated(); }
public void ContentShouldBeSetOnNavigatingToPage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); Assert.That(first, Is.EqualTo(target.Content)); target.NavigateTo(second); Assert.That(second, Is.SameAs(target.Content)); }
public void ContentShouldBeSetOnNavigatingBack() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.Back(); Assert.Same(first, target.Content); }
public void NavigatingToExistingPageInForwardHistoryShouldNotDisposePage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.Back(); target.NavigateTo(second); second.DidNotReceive().Dispose(); }
public void RemovesAllInstancesOfPage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.NavigateTo(second); target.NavigateTo(second); target.RemoveAll(second); Assert.Single(target.History); }
public void ClearsTheContentAndHistory() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.Clear(); Assert.Null(target.Content); Assert.False(target.NavigateBack.CanExecute(null)); Assert.False(target.NavigateForward.CanExecute(null)); }
public void BackShouldCallActivatedOnNewPage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); first.ClearReceivedCalls(); target.Back(); first.Received(1).Activated(); }
public void RemovingCurrentItemSetsContentToPrevious() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.RemoveAll(second); Assert.Same(first, target.Content); Assert.Same(first, target.History[0]); Assert.Equal(0, target.Index); Assert.Single(target.History); }
public void CloseRequestedShouldRemovePage() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); var close = new Subject <Unit>(); second.CloseRequested.Returns(close); target.NavigateTo(first); target.NavigateTo(second); close.OnNext(Unit.Default); Assert.Single(target.History); Assert.Same(first, target.History[0]); }
public void RemovingItemAfterCurrentWorks() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.Back(); target.RemoveAll(second); Assert.That(first, Is.SameAs(target.Content)); Assert.That(first, Is.SameAs(target.History[0])); Assert.That(0, Is.EqualTo(target.Index)); //Assert.Single(target.History); }
public void DoesntThrowWhenHistoryHasMoreThan10Items() { var target = new NavigationViewModel(); var pages = new List <IPanePageViewModel>(); for (var i = 0; i < 11; ++i) { var page = CreatePage(); pages.Add(page); target.NavigateTo(page); } foreach (var page in pages) { page.ClearReceivedCalls(); } target.Clear(); pages.Last().Received().Deactivated(); pages.Last().Received().Dispose(); foreach (var page in pages.Take(pages.Count - 1)) { page.DidNotReceive().Deactivated(); page.Received().Dispose(); } }
public void ContentShouldBeSetWhenReplacingFuture() { var target = new NavigationViewModel(); var first = CreatePage(); var second = CreatePage(); var third = CreatePage(); target.NavigateTo(first); target.NavigateTo(second); target.Back(); target.NavigateTo(third); Assert.Equal(third, target.Content); target.Back(); Assert.Equal(first, target.Content); }
public void ShouldCallActivatedOnNewPage() { var target = new NavigationViewModel(); var first = CreatePage(); target.NavigateTo(first); first.Received(1).Activated(); }
public void ForwardAndBackCommandsShouldBeDisabledOnNavigatingToFirstPage() { var target = new NavigationViewModel(); var first = CreatePage(); target.NavigateTo(first); Assert.False(target.NavigateBack.CanExecute(null)); Assert.False(target.NavigateForward.CanExecute(null)); }
public void RemovingItemDisposesRegisteredResources() { var target = new NavigationViewModel(); var first = CreatePage(); var disposed = false; target.NavigateTo(first); target.RegisterDispose(first, Disposable.Create(() => disposed = true)); target.RemoveAll(first); Assert.True(disposed); }
public void RemovingOnlyItemWorks() { var target = new NavigationViewModel(); var first = CreatePage(); target.NavigateTo(first); target.RemoveAll(first); Assert.Null(target.Content); Assert.Empty(target.History); Assert.Equal(-1, target.Index); }
public void RemovingItemCallsDispose() { var target = new NavigationViewModel(); var first = CreatePage(); var disposed = false; first.When(x => x.Dispose()).Do(_ => disposed = true); target.NavigateTo(first); target.RemoveAll(first); Assert.True(disposed); }
public void DisposesPages() { var target = new NavigationViewModel(); var first = CreatePage(); var disposed = false; first.When(x => x.Dispose()).Do(_ => disposed = true); target.NavigateTo(first); target.Clear(); Assert.True(disposed); }
public void CallsDeactivatedAndThenDisposedOnPages() { var target = new NavigationViewModel(); var first = CreatePage(); target.NavigateTo(first); target.RemoveAll(first); Received.InOrder(() => { first.Deactivated(); first.Dispose(); }); }
public void Execute(object parameter) { navigation.NavigateTo(targetView); DoSomethingWithParameter(parameter, targetView); }