Inheritance: BaseViewModel
Ejemplo n.º 1
0
        public void RefreshListCommandCallsList()
        {
            var mockNavigation = new MockMvxViewDispatcher();
            var mockNavigationProvider = new MockMvxViewDispatcherProvider();
            mockNavigationProvider.Dispatcher = mockNavigation;
            Ioc.RegisterServiceInstance<IMvxViewDispatcherProvider>(mockNavigationProvider);

            var spheroListService = new Mock<ISpheroListService>();
            Ioc.RegisterServiceInstance(spheroListService.Object);

            var viewModel = new HomeViewModel();
            viewModel.RefreshListCommand.Execute(null);

            spheroListService.Verify(service => service.RefreshList(), Times.Once());
        }
Ejemplo n.º 2
0
        public void GoToSpheroCommandCallsNavigate()
        {
            var mockNavigation = new MockMvxViewDispatcher();
            var mockNavigationProvider = new MockMvxViewDispatcherProvider();
            mockNavigationProvider.Dispatcher = mockNavigation;
            Ioc.RegisterServiceInstance<IMvxViewDispatcherProvider>(mockNavigationProvider);

            var spheroListService = new Mock<ISpheroListService>();
            Ioc.RegisterServiceInstance(spheroListService.Object);

            var mockAvailableSphero = new Mock<IAvailableSphero>();
            mockAvailableSphero.SetupGet(s => s.Name).Returns("TestSphero");

            var viewModel = new HomeViewModel();
            viewModel.GoToSpheroCommand.Execute(mockAvailableSphero.Object);

            Assert.That(mockNavigation.NavigateRequests.Count == 1);
            Assert.That(mockNavigation.NavigateRequests.First().ViewModelType == typeof (SpheroViewModel));
            Assert.That(mockNavigation.NavigateRequests.First().ParameterValues.Count == 1);
            Assert.That(mockNavigation.NavigateRequests.First().ParameterValues["name"] == "TestSphero");
        }