public async Task Should_Observe_Pushed() { // Given PopupNavigationEvent pushing = null; var viewModel = new NavigableViewModelMock(); var popup = new PopupMock { ViewModel = viewModel }; var navigation = Substitute.For <IPopupNavigation>(); var viewLocator = Substitute.For <IViewLocator>(); viewLocator.ResolveView(Arg.Any <IViewModel>()).Returns(popup); PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation).WithViewLocator(viewLocator); sut.Pushed.Subscribe(x => pushing = x); // When await sut.PushPopup(viewModel); navigation.Pushed += Raise.EventWith(new PopupNavigationEventArgs(popup, true)); // Then pushing.ViewModel.Should().Be(viewModel); }
public void Should_Observe_Pushing() { // Given PopupNavigationEvent?pushing = null; var viewModel = new NavigableViewModelMock(); var popup = new PopupMock { ViewModel = viewModel }; var navigation = Substitute.For <IPopupNavigation>(); PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation); sut.Pushing.Subscribe(x => pushing = x); // When navigation.Pushing += Raise.EventWith(new PopupNavigationEventArgs(popup, true)); if (pushing is null) { throw new InvalidOperationException("pushing should not be null."); } // Then pushing.ViewModel.Should().Be(viewModel); }
public void Should_Call_Destroy() { // Given PopupNavigationEvent pushing = null; var viewModel = Substitute.For <IEverything>(); var popup = new PopupMock { ViewModel = viewModel }; var navigation = Substitute.For <IPopupNavigation>(); PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation); sut.Popped.Subscribe(x => pushing = x); // When navigation.Popped += Raise.EventWith(new PopupNavigationEventArgs(popup, true)); // Then ((IDestructible)popup.ViewModel).Received(1).Destroy(); }
public void Should_Observe_Popped() { // Given PopupNavigationEvent pushing = null; var viewModel = new NavigableViewModelMock(); var popup = new PopupMock { ViewModel = viewModel }; var navigation = Substitute.For <IPopupNavigation>(); PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation); sut.Popped.Subscribe(x => pushing = x); // When navigation.Popped += Raise.EventWith(new PopupNavigationEventArgs(popup, true)); // Then pushing.ViewModel.Should().Be(viewModel); }
public async Task Should_Call_Destroy() { // Given var viewModel = Substitute.For <IEverything>(); var popup = new PopupMock { ViewModel = viewModel }; bool pushed = false; PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(new PopupNavigationMock()); sut.Popped.Select(_ => true).Subscribe(x => pushed = x); // When await sut.PushPopup(viewModel); await sut.RemovePopup(viewModel); // Then ((IDestructible)popup.ViewModel).Received(1).Destroy(); }