Example #1
0
            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);
            }
Example #3
0
            public async Task Should_Call_Popup_Navigation()
            {
                // Given
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation);

                // When
                await sut.RemovePopup(new NavigableViewModelMock());

                // Then
                await navigation.Received(1).RemovePageAsync(Arg.Any <PopupPage>()).ConfigureAwait(false);
            }
Example #4
0
            public async Task Should_Call_Popup_Navigation()
            {
                // Given
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation);

                // When
                await sut.PopPopup();

                // Then
                await navigation.Received(1).PopAsync(Arg.Any <bool>()).ConfigureAwait(false);
            }
Example #5
0
            public async Task Should_Observe_Pushed()
            {
                // Given
                bool pushed = false;
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(new PopupNavigationMock());

                sut.Pushed.Select(_ => true).Subscribe(x => pushed = x);

                // When
                await sut.PushPopup <NavigableViewModelMock>();

                // Then
                pushed.Should().BeTrue();
            }
Example #6
0
            public async Task Should_Call_View_Locator()
            {
                // Given
                var viewLocator = Substitute.For <IViewLocator>();

                viewLocator.ResolveView(Arg.Any <IViewModel>()).Returns(new PopupMock());
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithViewLocator(viewLocator);

                // When
                await sut.PushPopup <NavigableViewModelMock>();

                // Then
                viewLocator.Received(1).ResolveView(Arg.Any <IViewModel>());
            }
Example #7
0
            public async Task Should_Call_View_Model_Factory()
            {
                // Given
                var viewModelFactory = Substitute.For <IViewModelFactory>();

                viewModelFactory.Create <NavigableViewModelMock>(Arg.Any <string>()).Returns(new NavigableViewModelMock());
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithViewModelFactory(viewModelFactory);

                // When
                await sut.PushPopup <NavigableViewModelMock>();

                // Then
                viewModelFactory.Received(1).Create <NavigableViewModelMock>();
            }
Example #8
0
            public async Task Should_Observe_Pushing()
            {
                // Given
                bool pushing              = false;
                var  parameter            = new NavigationParameter();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(new PopupNavigationMock());

                sut.Pushing.Select(_ => true).Subscribe(x => pushing = x);

                // When
                await sut.PushPopup(new NavigableViewModelMock(), parameter);

                // Then
                pushing.Should().BeTrue();
            }
Example #9
0
            public async Task Should_Call_Navigating_To()
            {
                // Given
                var parameter   = new NavigationParameter();
                var viewLocator = Substitute.For <IViewLocator>();
                var viewModel   = Substitute.For <INavigable>();

                viewLocator.ResolveView(Arg.Any <NavigableViewModelMock>(), Arg.Any <string>()).Returns(new PopupMock());
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation);

                // When
                await sut.PushPopup(viewModel, parameter);

                // Then
                await viewModel.Received(1).WhenNavigatingTo(parameter);
            }
Example #10
0
            public async Task Should_Call_Navigating_To()
            {
                // Given
                var parameter   = new NavigationParameter();
                var viewModel   = Substitute.For <AbstractViewModel>();
                var viewLocator = Substitute.For <IViewLocator>();

                viewLocator.ResolveView(Arg.Any <AbstractViewModel>()).Returns(new PopupMock());
                var factory = Substitute.For <IViewModelFactory>();

                factory.Create <AbstractViewModel>(Arg.Any <string>()).Returns(viewModel);
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation).WithViewModelFactory(factory).WithViewLocator(viewLocator);

                // When
                await sut.PushPopup <AbstractViewModel>(parameter);

                // Then
                await viewModel.Received(1).WhenNavigatingTo(parameter);
            }
Example #11
0
            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();
            }
Example #12
0
            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);
            }
Example #13
0
            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();
            }