public void RouteToErrorViewWhenThingsGoPearShaped() { var router = new RoutingState(); var detectComplete = new Subject <DetectPackageCompleteEventArgs>(); var error = new Subject <ErrorEventArgs>(); var events = new Mock <IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectComplete); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(Observable.Never <PlanCompleteEventArgs>()); events.SetupGet(x => x.ApplyCompleteObs).Returns(Observable.Never <ApplyCompleteEventArgs>()); string dir; using (IntegrationTestHelper.WithFakeInstallDirectory(out dir)) { var fixture = new WixUiBootstrapper(events.Object, null, router, null, dir); RxApp.GetAllServices <ICreatesObservableForProperty>().Any().ShouldBeTrue(); detectComplete.OnNext(new DetectPackageCompleteEventArgs("Foo", packHResultIntoIntEvenThoughItShouldntBeThere(0x80004005), PackageState.Unknown)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(ErrorViewModel)); router.NavigateAndReset.Execute(RxApp.GetService <IWelcomeViewModel>()); error.OnNext(new ErrorEventArgs(ErrorType.ExePackage, "Foo", packHResultIntoIntEvenThoughItShouldntBeThere(0x80004005), "Noope", 0, new string[0], 0)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(ErrorViewModel)); } }
public void RouteToErrorViewWhenThingsGoPearShaped() { var router = new RoutingState(); var detectComplete = new Subject<DetectPackageCompleteEventArgs>(); var error = new Subject<ErrorEventArgs>(); var events = new Mock<IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectComplete); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(Observable.Never<PlanCompleteEventArgs>()); events.SetupGet(x => x.ApplyCompleteObs).Returns(Observable.Never<ApplyCompleteEventArgs>()); events.SetupGet(x => x.Engine).Returns(Mock.Of<IEngine>()); string dir; using (IntegrationTestHelper.WithFakeInstallDirectory(out dir)) { var fixture = new WixUiBootstrapper(events.Object, null, router, null, dir); RxApp.GetAllServices<ICreatesObservableForProperty>().Any().ShouldBeTrue(); Func<uint, int> convertHResult = hr => BitConverter.ToInt32(BitConverter.GetBytes(hr), 0); detectComplete.OnNext(new DetectPackageCompleteEventArgs("UserApplicationId", convertHResult(0x80004005), PackageState.Unknown)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(ErrorViewModel)); router.NavigateAndReset.Execute(RxApp.GetService<IWelcomeViewModel>()); error.OnNext(new ErrorEventArgs(ErrorType.ExePackage, "UserApplicationId", convertHResult(0x80004005), "Noope", 0, new string[0], 0)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(ErrorViewModel)); } }
public void RouteToUninstallOnDetectPackageComplete() { var router = new RoutingState(); var detectComplete = new Subject <DetectPackageCompleteEventArgs>(); var error = new Subject <ErrorEventArgs>(); var events = new Mock <IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectComplete); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(Observable.Never <PlanCompleteEventArgs>()); events.SetupGet(x => x.ApplyCompleteObs).Returns(Observable.Never <ApplyCompleteEventArgs>()); events.SetupGet(x => x.DisplayMode).Returns(Display.Full); events.SetupGet(x => x.Action).Returns(LaunchAction.Uninstall); var engine = new Mock <IEngine>(); engine.Setup(x => x.Plan(LaunchAction.Uninstall)).Verifiable(); events.SetupGet(x => x.Engine).Returns(engine.Object); string dir; using (IntegrationTestHelper.WithFakeInstallDirectory(out dir)) { var fixture = new WixUiBootstrapper(events.Object, null, router, null, dir); RxApp.GetAllServices <ICreatesObservableForProperty>().Any().ShouldBeTrue(); detectComplete.OnNext(new DetectPackageCompleteEventArgs("Foo", 0, PackageState.Absent)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(UninstallingViewModel)); engine.Verify(x => x.Plan(LaunchAction.Uninstall), Times.Once()); } }
public void RouteToInstallOnDetectPackageComplete() { var router = new RoutingState(); var detectComplete = new Subject<DetectPackageCompleteEventArgs>(); var error = new Subject<ErrorEventArgs>(); var events = new Mock<IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectComplete); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(Observable.Never<PlanCompleteEventArgs>()); events.SetupGet(x => x.ApplyCompleteObs).Returns(Observable.Never<ApplyCompleteEventArgs>()); events.SetupGet(x => x.DisplayMode).Returns(Display.Full); events.SetupGet(x => x.Action).Returns(LaunchAction.Install); events.SetupGet(x => x.Engine).Returns(Mock.Of<IEngine>()); string dir; using (IntegrationTestHelper.WithFakeInstallDirectory(out dir)) { var fixture = new WixUiBootstrapper(events.Object, null, router, null, dir); RxApp.GetAllServices<ICreatesObservableForProperty>().Any().ShouldBeTrue(); detectComplete.OnNext(new DetectPackageCompleteEventArgs("UserApplicationId", 0, PackageState.Absent)); router.GetCurrentViewModel().GetType().ShouldEqual(typeof(WelcomeViewModel)); } }
public void NavigatingToPlayWithCredsShouldStayOnPlay() { var kernel = new MoqMockingKernel(); var router = new RoutingState(); var fixture = setupStandardMock(kernel, router); router.Navigate.Execute(fixture); (router.GetCurrentViewModel() is IPlayViewModel).Should().BeTrue(); }
public static async Task NavigateIfNotAlready <T>(this RoutingState state, Func <Task <T> > objCreator) { var currentViewModel = state.GetCurrentViewModel(); if (currentViewModel.GetType() == typeof(T)) { return; } await state.Navigate.ExecuteAsyncTask(await objCreator().ConfigureAwait(false)).ConfigureAwait(false); }
public void LogoutButtonShouldSendMeToWelcomePage() { var kernel = new MoqMockingKernel(); var router = new RoutingState(); var fixture = setupStandardMock(kernel, router); router.Navigate.Execute(fixture); fixture.Logout.Execute(null); (router.GetCurrentViewModel() is IPlayViewModel).Should().BeFalse(); }