public async Task Test_NavigateTypeOfNoBundle()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            await navigationService.Navigate(typeof(SimpleTestViewModel));

            MockLoader.Verify(loader => loader.LoadViewModel(It.Is <MvxViewModelRequest>(val => val.ViewModelType == typeof(SimpleTestViewModel)), It.IsAny <IMvxBundle>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleTestViewModel))),
                Times.Once);
        }
예제 #2
0
        public async Task Test_NavigateNoBundle()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            await navigationService.Navigate <SimpleTestViewModel>().ConfigureAwait(false);

            Assert.NotNull(MockLoader);
            MockLoader?.Verify(loader => loader.LoadViewModel(It.Is <MvxViewModelRequest>(val => val.ViewModelType == typeof(SimpleTestViewModel)), It.IsAny <IMvxBundle>(), It.IsAny <IMvxNavigateEventArgs>()),
                               Times.Once);

            MockDispatcher?.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleTestViewModel))),
                Times.Once);
        }
        public async Task Test_NavigateForResult()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var result = await navigationService.Navigate <SimpleResultTestViewModel, bool>();

            MockLoader.Verify(loader => loader.LoadViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleResultTestViewModel)), It.IsAny <IMvxBundle>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleResultTestViewModel))),
                Times.Once);

            Assert.True(MockDispatcher.Object.Requests.Count > 0);
            Assert.True(result);
        }
        public async Task Test_NavigateTypeOfWithParameter()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var parameter = "hello";
            await navigationService.Navigate <string>(typeof(SimpleParameterTestViewModel), parameter);

            MockLoader.Verify(loader => loader.LoadViewModel <string>(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleParameterTestViewModel)), It.Is <string>(val => val == parameter), It.IsAny <IMvxBundle>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleParameterTestViewModel))),
                Times.Once);

            Assert.True(MockDispatcher.Object.Requests.Count > 0);
        }
예제 #5
0
        public async Task Test_NavigateWithParameter()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var parameter = "hello";
            await navigationService.Navigate <SimpleParameterTestViewModel, SimpleParameter>(new SimpleParameter { Hello = parameter });

            MockLoader.Verify(loader => loader.LoadViewModel <SimpleParameter>(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleParameterTestViewModel)), It.Is <SimpleParameter>(val => val.Hello == parameter), It.IsAny <IMvxBundle>(), It.IsAny <IMvxNavigateEventArgs>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelRequest>(t => t.ViewModelType == typeof(SimpleParameterTestViewModel))),
                Times.Once);

            Assert.NotEmpty(MockDispatcher.Object.Requests);
        }
        public async Task Test_NavigateViewModelInstance()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var mockVm = new Mock <SimpleTestViewModel>();

            await navigationService.Navigate(mockVm.Object);

            MockLoader.Verify(loader => loader.ReloadViewModel(It.Is <SimpleTestViewModel>(val => mockVm.Object == val), It.IsAny <MvxViewModelRequest>(), It.IsAny <IMvxBundle>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelInstanceRequest>(t => t.ViewModelInstance == mockVm.Object)),
                Times.Once);

            Assert.True(MockDispatcher.Object.Requests.Count > 0);
        }
예제 #7
0
        public async Task Test_NavigateViewModelInstanceWithParameter()
        {
            var navigationService = Ioc.Resolve <IMvxNavigationService>();

            var mockVm = new Mock <SimpleParameterTestViewModel>();

            var parameter = "hello";
            await navigationService.Navigate <string>(mockVm.Object, parameter);

            MockLoader.Verify(loader => loader.ReloadViewModel <string>(It.Is <SimpleParameterTestViewModel>(val => mockVm.Object == val), It.Is <string>(val => val == parameter), It.IsAny <MvxViewModelRequest>(), It.IsAny <IMvxBundle>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelInstanceRequest>(t => t.ViewModelInstance == mockVm.Object)),
                Times.Once);

            Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0);
        }
예제 #8
0
        public async Task Test_NavigateViewModelInstanceWithParameter()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var mockVm = new Mock <SimpleParameterTestViewModel>();

            var parameter = new SimpleParameter {
                Hello = "hello"
            };
            await navigationService.Navigate <SimpleParameter>(mockVm.Object, parameter);

            MockLoader.Verify(loader => loader.ReloadViewModel <SimpleParameter>(It.Is <SimpleParameterTestViewModel>(val => mockVm.Object == val), It.Is <SimpleParameter>(val => val.Hello == parameter.Hello), It.IsAny <MvxViewModelRequest>(), It.IsAny <IMvxBundle>(), It.IsAny <IMvxNavigateEventArgs>()),
                              Times.Once);

            MockDispatcher.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelInstanceRequest>(t => t.ViewModelInstance == mockVm.Object)),
                Times.Once);

            Assert.NotEmpty(MockDispatcher.Object.Requests);
        }
예제 #9
0
        public async Task Test_NavigateViewModelInstance()
        {
            var navigationService = _fixture.Ioc.Resolve <IMvxNavigationService>();

            var mockVm = new Mock <SimpleTestViewModel>();

            await navigationService.Navigate(mockVm.Object).ConfigureAwait(false);

            Assert.NotNull(MockLoader);

            MockLoader?.Verify(loader => loader.ReloadViewModel(It.Is <SimpleTestViewModel>(val => mockVm.Object == val), It.IsAny <MvxViewModelRequest>(), It.IsAny <IMvxBundle>(), It.IsAny <IMvxNavigateEventArgs>()),
                               Times.Once);

            Assert.NotNull(MockDispatcher);
            MockDispatcher?.Verify(
                x => x.ShowViewModel(It.Is <MvxViewModelInstanceRequest>(t => t.ViewModelInstance == mockVm.Object)),
                Times.Once);

            Assert.NotEmpty(MockDispatcher?.Object.Requests);
        }