public void WhenNavigatedToObservable() { using (_mockViewModel !().WhenNavigatedToObservable().Subscribe(x => Console.WriteLine("Observed"))) using (_router !.Navigate.Execute(_mockViewModel()).Subscribe()) { } }
public void Navigate() { using (_router !.Navigate.Execute(_mockViewModel()).Subscribe()) { _router.NavigationStack.ToList(); } }
public void ExecuteDoesNotThrowExceptionWithNullParameter() { // Arrange var processStarter = Mock.Of <IProcessStarter>(); var command = new Navigate(processStarter); // Act Assert.DoesNotThrow(() => command.Execute(null)); // Assert Mock.Get(processStarter).Verify(p => p.StartNewProcess( It.IsAny <ProcessStartInfo>()), Times.Never); }
public void ExecuteStartsNewProcessWithAbsoluteUri() { // Arrange var uri = new Uri("https://github.com/Ant-f"); var processStarter = Mock.Of <IProcessStarter>(); var command = new Navigate(processStarter); // Act command.Execute(uri); // Assert Mock.Get(processStarter).Verify(p => p.StartNewProcess(It.Is <ProcessStartInfo>(i => i.FileName == uri.AbsoluteUri))); }
void setupRx() { var scheduler = this.scheduler ?? RxApp.MainThreadScheduler; var countAsBehavior = Observable.Concat( Observable.Defer(() => Observable.Return(_NavigationStack.Count)), NavigationStack.CountChanged); NavigateBack = ReactiveCommand.CreateFromObservable(() => { NavigationStack.RemoveAt(NavigationStack.Count - 1); return(Observables.Unit); }, countAsBehavior.Select(x => x > 1), scheduler); Navigate = ReactiveCommand.CreateFromObservable <IRoutableViewModel, IRoutableViewModel>(x => { var vm = x as IRoutableViewModel; if (vm == null) { throw new Exception("Navigate must be called on an IRoutableViewModel"); } NavigationStack.Add(vm); return(Observable.Return(x)); }, outputScheduler: scheduler); NavigateAndReset = ReactiveCommand.CreateFromObservable <IRoutableViewModel, IRoutableViewModel>(x => { NavigationStack.Clear(); return(Navigate.Execute(x)); }, outputScheduler: scheduler); CurrentViewModel = Observable.Concat( Observable.Defer(() => Observable.Return(NavigationStack.LastOrDefault())), NavigationStack.Changed.Select(_ => NavigationStack.LastOrDefault())); }