public void WhenNavigatedToCallsDisposeWhenNavigationStackIsReset() { var count = 0; var screen = new TestScreen(); var vm1 = new RoutableViewModel(screen); var vm2 = new RoutableViewModel(screen); vm1.WhenNavigatedTo(() => { return(Disposable.Create(() => count++)); }); screen.Router.Navigate.Execute(vm1); Assert.Equal(0, count); screen.Router.NavigateAndReset.Execute(vm2); Assert.Equal(1, count); }
public void WhenNavigatedToCallsOnNavigatedToWhenViewModelReturnsToTopOfStack() { var count = 0; var screen = new TestScreen(); var vm = new RoutableViewModel(screen); var vm2 = new RoutableViewModel(screen); vm.WhenNavigatedTo(() => { count++; return Disposable.Empty; }); screen.Router.Navigate.Execute(vm); screen.Router.Navigate.Execute(vm2); screen.Router.Navigate.Execute(vm); Assert.Equal(2, count); }
public void CurrentViewModelObservableIsAccurateViaWhenAnyObservable() { var fixture = new TestScreen(); fixture.WhenAnyObservable(x => x.Router !.CurrentViewModel).ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var output).Subscribe(); fixture.Router = new RoutingState(); Assert.Equal(1, output.Count); fixture.Router.Navigate.Execute(new TestViewModel { SomeProp = "A" }); Assert.Equal(2, output.Count); fixture.Router.Navigate.Execute(new TestViewModel { SomeProp = "B" }); Assert.Equal(3, output.Count); Assert.Equal("B", ((TestViewModel)output.Last()).SomeProp); fixture.Router.NavigateBack.Execute(); Assert.Equal(4, output.Count); Assert.Equal("A", ((TestViewModel)output.Last()).SomeProp); }