protected override void AdditionalSetup() { _fixture = new Fixture().Customize(new AutoMoqCustomization()); _driver = _fixture.Create <Driver>(); _mockInfoService = _fixture.InjectNewMock <IInfoService>(); _mockInfoService.Setup(ms => ms.CurrentDriverID).Returns(_driver.ID); _mobileDataRepoMock = _fixture.InjectNewMock <IMobileDataRepository>(); _mockNavigationService = _fixture.InjectNewMock <INavigationService>(); Ioc.RegisterSingleton <INavigationService>(_mockNavigationService.Object); _fixture.Inject <IRepositories>(_fixture.Create <Repositories>()); _mockGatewayPollingService = _fixture.InjectNewMock <IGatewayPollingService>(); Ioc.RegisterSingleton <IMvxMessenger>(_fixture.InjectNewMock <IMvxMessenger>().Object); // Mock dispatcher required so that InvokeOnMainThread() delegate is executed inside view model's ReloadPageAsync() var dispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); Ioc.RegisterSingleton <IMvxViewDispatcher>(dispatcher); }
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"); }
protected MockMvxViewDispatcher CreateMockNavigation() { var dispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); Ioc.RegisterSingleton <IMvxViewDispatcher>(dispatcher); return(dispatcher); }
protected MockMvxViewDispatcher CreateMockNavigation() { var mockNavigation = new MockMvxViewDispatcher(); var mockNavigationProvider = new MockMvxViewDispatcherProvider(); mockNavigationProvider.Dispatcher = mockNavigation; Ioc.RegisterServiceInstance <IMvxViewDispatcherProvider>(mockNavigationProvider); return(mockNavigation); }
protected MockMvxViewDispatcher CreateMockNavigation() { var dispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); Ioc.RegisterSingleton <IMvxViewDispatcher>(dispatcher); Ioc.RegisterSingleton <IMvxMessenger>(_messenger.Object); Ioc.RegisterSingleton <ISettings>(_settings.Object); Ioc.RegisterSingleton <IPhoneService>(_phoneService.Object); return(dispatcher); }
public void SetUp() { ClearAll(); _fixture = new Fixture().Customize(new AutoMoqCustomization()); recipeRepoMock = _fixture.Freeze <Mock <IRecipeRepo> >(); messengerMock = _fixture.Freeze <Mock <IMvxMessenger> >(); mockDispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxViewDispatcher>(mockDispatcher); Ioc.RegisterSingleton <MvxMainThreadDispatcher>(mockDispatcher); }
public void GoCausesNavigationForNonEmptySearch() { var mockNavigation = new MockMvxViewDispatcher(); var mockNavigationProvider = new MockMvxViewDispatcherProvider(); mockNavigationProvider.Dispatcher = mockNavigation; Ioc.RegisterServiceInstance <IMvxViewDispatcherProvider>(mockNavigationProvider); var viewModel = new HomeViewModel(); var searchTerm = "Test Search Term"; viewModel.SearchText = searchTerm; viewModel.SearchCommand.Execute(null); Assert.AreEqual(1, mockNavigation.NavigateRequests.Count); }
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()); }
public void SetUp() { MvxSingleton.ClearAllSingletons(); ClearAll(); Dispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(Dispatcher); Ioc.RegisterSingleton <IMvxViewDispatcher>(Dispatcher); DataClient = new MockCampDataClient(); Messenger = new MvxMessengerHub(); CodeCampService = new CodeCampService(new InMemoryFileManager(), new MvxJsonConverter(), DataClient); ComposeEmailTask = new MockComposeEmailTask(); WebBrowserTask = new MockWebBrowserTask(); Mvx.RegisterSingleton <IMvxStringToTypeParser>(new MvxStringToTypeParser()); SetUpFixture(); }
public void SetUp() { ClearAll(); _fixture = new Fixture().Customize(new AutoMoqCustomization()); alarmBellMock = _fixture.Freeze <Mock <IAlarmBell> >(); recipeRepoMock = _fixture.Freeze <Mock <IRecipeRepo> >(); shareTaskMock = _fixture.Freeze <Mock <IMvxShareTask> >(); messengerMock = _fixture.Freeze <Mock <IMvxMessenger> >(); SetupPublisherForActiveRecipeMessage(); recipeViewModel = _fixture.Create <RecipeViewModel>(); mockDispatcher = new MockMvxViewDispatcher(); Ioc.RegisterSingleton <IMvxViewDispatcher>(mockDispatcher); Ioc.RegisterSingleton <MvxMainThreadDispatcher>(mockDispatcher); }