Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        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);
        }
Beispiel #12
0
        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();
            }
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        public void ShouldCallActivatedOnNewPage()
        {
            var target = new NavigationViewModel();
            var first  = CreatePage();

            target.NavigateTo(first);

            first.Received(1).Activated();
        }
Beispiel #15
0
        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));
        }
Beispiel #16
0
        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);
        }
Beispiel #17
0
        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);
        }
Beispiel #18
0
        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);
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
        public void CallsDeactivatedAndThenDisposedOnPages()
        {
            var target = new NavigationViewModel();
            var first  = CreatePage();

            target.NavigateTo(first);
            target.RemoveAll(first);

            Received.InOrder(() =>
            {
                first.Deactivated();
                first.Dispose();
            });
        }
Beispiel #21
0
 public void Execute(object parameter)
 {
     navigation.NavigateTo(targetView);
     DoSomethingWithParameter(parameter, targetView);
 }