static void mockPerformInstall( string installDirectory, string targetRootDirectory) { var kernel = new TinyIoCContainer(); kernel.Register(Mock.Of <IProcessFactory>()); var router = new RoutingState(); var detectPackage = new Subject <DetectPackageCompleteEventArgs>(); var planComplete = new Subject <PlanCompleteEventArgs>(); var applyComplete = new Subject <ApplyCompleteEventArgs>(); var error = new Subject <ErrorEventArgs>(); var engine = new Mock <IEngine>(); var events = new Mock <IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectPackage); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(planComplete); events.SetupGet(x => x.ApplyCompleteObs).Returns(applyComplete); events.SetupGet(x => x.Engine).Returns(engine.Object); events.SetupGet(x => x.DisplayMode).Returns(Display.Full); events.SetupGet(x => x.Action).Returns(LaunchAction.Install); var installer = new WixUiBootstrapper(events.Object, kernel, router, null, installDirectory, targetRootDirectory); mockPerformInstall(router, detectPackage, planComplete, applyComplete, engine); }
public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); RegisterAkavache(); RegisterServices(); RegisterViewModels(); UserError.RegisterHandler(ue => { var notificator = DependencyService.Get <IToastNotificator>(); notificator.Notify( ToastNotificationType.Error, ue.ErrorMessage, ue.InnerException.ToString(), TimeSpan.FromSeconds(20)); this.Log().ErrorException(ue.ErrorMessage, ue.InnerException); return(Observable.Return(RecoveryOptionResult.CancelOperation)); }); Router.Navigate.Execute(new LoadingViewModel()); }
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)); } }
/// <summary> /// Initializes a new instance of the <see cref="AppBootstrapper"/> class. /// </summary> public AppBootstrapper() { // Create a new Router. Router = new RoutingState(); // Register this class instance as IScreen. Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); RegisterViews(); RegisterViewModels(); // Load main page. Router.NavigateAndReset.Execute(new MainViewModel()).Subscribe(); Router .NavigationChanged .Where(x => x != null) .DistinctUntilChanged() .ForEachChange(x => { if (x.Item.Reason == ListChangeReason.Add) { Console.WriteLine( $"ADD: {x.Item.Current?.UrlPathSegment} COUNT: {Router.NavigationStack.Count} TIME: {DateTime.Now}\n\n\n"); } else if (x.Item.Reason == ListChangeReason.Remove) { Console.WriteLine( $"REMOVE: {x.Item.Current?.UrlPathSegment} COUNT: {Router.NavigationStack.Count} TIME: {DateTime.Now}\n\n\n"); } }).Subscribe(); }
public void NavigationPushPopTest() { var input = new TestViewModel() { SomeProp = "Foo" }; var fixture = new RoutingState(); RxApp.ConfigureServiceLocator( (t, s) => new TestViewModel() { SomeProp = "Foo" }, (t, s) => Enumerable.Empty <object>(), (c, t, s) => { }); Assert.False(fixture.NavigateBack.CanExecute(input)); fixture.Navigate.Go <TestViewModel>(); Assert.Equal(1, fixture.NavigationStack.Count); Assert.True(fixture.NavigateBack.CanExecute(null)); fixture.NavigateBack.Execute(null); Assert.Equal(0, fixture.NavigationStack.Count); }
public void CurrentViewModelObservableIsAccurate() { var fixture = new RoutingState(); fixture.CurrentViewModel.ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var output).Subscribe(); Assert.Equal(1, output.Count); fixture.Navigate.Execute(new TestViewModel() { SomeProp = "A" }); Assert.Equal(2, output.Count); fixture.Navigate.Execute(new TestViewModel() { SomeProp = "B" }); Assert.Equal(3, output.Count); Assert.Equal("B", ((TestViewModel)output.Last()).SomeProp); fixture.NavigateBack.Execute(); Assert.Equal(4, output.Count); Assert.Equal("A", ((TestViewModel)output.Last()).SomeProp); }
public MasterViewModel() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); MenuItems = GetMenuItems(); NavigateToMenuItem = ReactiveCommand.CreateFromObservable <IRoutableViewModel, Unit>( routableVm => Router.NavigateAndReset.Execute(routableVm).Select(_ => Unit.Default)); this.WhenAnyValue(x => x.Selected) .Where(x => x != null) .StartWith(MenuItems.First()) .Select(x => Locator.Current.GetService <IRoutableViewModel>(x.TargetType.FullName)) .InvokeCommand(NavigateToMenuItem); ShareCommand = ReactiveCommand.Create(async() => { await Share.RequestAsync(new ShareTextRequest { Uri = "https://curaciov.com" }); }); LikeCommand = ReactiveCommand.Create(() => { Launcher.OpenAsync(new Uri(@"https://curaciov.com")); }); }
public MainViewModel() { // Initialize the Router. Router = new RoutingState(); // Router uses Splat.Locator to resolve views for // view models, so we need to register our views // using Locator.CurrentMutable.Register* methods. // // Instead of registering views manually, you // can use custom IViewLocator implementation, // see "View Location" section for details. // Locator.CurrentMutable.Register(() => new AboutView(), typeof(IViewFor <AboutViewModel>)); // Manage the routing state. Use the Router.Navigate.Execute // command to navigate to different view models. // // Note, that the Navigate.Execute method accepts an instance // of a view model, this allows you to pass parameters to // your view models, or to reuse existing view models. // GoNext = ReactiveCommand.CreateFromObservable(() => Router.Navigate.Execute(new AboutViewModel())); // You can also ask the router to go back. GoBack = Router.NavigateBack; }
public void NavigationPushPopTest() { var input = new TestViewModel() {SomeProp = "Foo"}; var fixture = new RoutingState(); RxApp.ConfigureServiceLocator( (t, s) => new TestViewModel() {SomeProp = "Foo"}, (t, s) => Enumerable.Empty<object>(), (c, t, s) => { }); Assert.False(fixture.NavigateBack.CanExecute(input)); fixture.Navigate.Go<TestViewModel>(); Assert.Equal(1, fixture.NavigationStack.Count); Assert.False(fixture.NavigateBack.CanExecute(null)); fixture.Navigate.Go<TestViewModel>(); Assert.Equal(2, fixture.NavigationStack.Count); Assert.True(fixture.NavigateBack.CanExecute(null)); fixture.NavigateBack.Execute(null); Assert.Equal(1, fixture.NavigationStack.Count); }
// Token: 0x060018A0 RID: 6304 RVA: 0x0002BBA0 File Offset: 0x0002ABA0 public RoutingState HitTrigger(InstancedEvent evnt, EntrantInfo entrant, RoutingState s) { CircuitRoutingState circuitRoutingState = s as CircuitRoutingState; if (circuitRoutingState != null) { if (circuitRoutingState.NextIndex >= evnt.Route.Count) { circuitRoutingState.Lap++; RouteScoringMethod routeScoringMethod = evnt.ScoringMethod as RouteScoringMethod; if (routeScoringMethod != null) { routeScoringMethod.OnLapCompleted(entrant, evnt, circuitRoutingState.Lap); } if (circuitRoutingState.Lap >= evnt.NumLaps) { circuitRoutingState.CurrentTarget = null; circuitRoutingState.IsRoutingFinished = true; return(circuitRoutingState); } circuitRoutingState.NextIndex = 0; } circuitRoutingState.CurrentTarget = evnt.Route[circuitRoutingState.NextIndex++]; return(circuitRoutingState); } s.CurrentTarget = null; s.IsRoutingFinished = true; return(s); }
public void AppStateShouldBeSetOnRepairClicked() { var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); IRoutableViewModel latestVm = null; var fixture = setupStandardFixture(router, kernel, () => { var branchInfo = new Dictionary <string, HeuristicTreeInformation>() { { "Working Directory", new HeuristicTreeInformation("derp", true) } }; kernel.Get <IRepoAnalysisProvider>().AnalyzeRepo(null) .ReturnsForAnyArgs(Observable.Return(Tuple.Create("foo", branchInfo))); router.ViewModelObservable().Subscribe(x => latestVm = x); }); fixture.AnalyzeRepo.Execute("foo"); fixture.RepairButtonVisibility.ShouldEqual(Visibility.Visible); fixture.RepairButton.Execute(null); var result = kernel.Get <IAppState>(); (latestVm is IRepairViewModel).ShouldBeTrue(); result.CurrentRepo.ShouldEqual("foo"); result.BranchInformation.ShouldNotBeNull(); }
public void ScanningOurselvesShouldReturnResults() { var repoRootPath = CoreUtility.FindRepositoryRoot(IntegrationTestHelper.GetIntegrationTestRootDirectory()); var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); var fixture = setupStandardFixture(router, kernel, () => kernel.Bind <IRepoAnalysisProvider>().To <RepoAnalysisProvider>()); fixture.AnalyzeRepo.Execute(repoRootPath); fixture.AnalyzeRepo.ItemsInflight.Where(x => x == 0).First(); fixture.BranchInformation.ShouldNotBeNull(); fixture.CurrentRepoPath.ShouldEqual(repoRootPath); this.Log().Info(JsonConvert.SerializeObject(fixture.BranchInformation, Formatting.Indented)); // We should have both the WD and the branches fixture.BranchInformation.Any(x => x.BranchName.ToLowerInvariant().Contains("working")).ShouldBeTrue(); fixture.BranchInformation.Any(x => x.BranchName.ToLowerInvariant().Contains("master")).ShouldBeTrue(); // We should have examined some files fixture.BranchInformation.All(x => x.BadEncodingInfoHeader != null).ShouldBeTrue(); fixture.BranchInformation.All(x => x.BadEndingsInfoHeader != null).ShouldBeTrue(); fixture.BranchInformation.All(x => x.Model.TotalFilesExamined > 0).ShouldBeTrue(); // .gitignored files shouldn't show up var working = fixture.BranchInformation.First(x => x.BranchName == Constants.WorkingDirectory); working.Model.BadLineEndingFiles.Any(x => x.Key.ToLowerInvariant().Contains("_resharper")).ShouldBeFalse(); }
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 AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); Locator.CurrentMutable.RegisterLazySingleton(() => new NativeMessageHandler(), typeof(HttpMessageHandler)); Locator.CurrentMutable.Register(() => new LoginPage(), typeof(IViewFor<LoginViewModel>)); Locator.CurrentMutable.Register(() => new RoomsPage(), typeof(IViewFor<RoomsViewModel>)); //Locator.CurrentMutable.Register(() => new MessagesPage(), typeof(IViewFor<MessagesViewModel>)); LoginInfo loginInfo = BlobCache.Secure.GetLoginAsync("Gitter") .Catch<LoginInfo, KeyNotFoundException>(ex => Observable.Return((LoginInfo)null)) .Wait(); if (loginInfo == null) { this.Router.Navigate.Execute(new LoginViewModel()); } else { this.Router.Navigate.Execute(new RoomsViewModel()); } }
public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); // Set up Akavache // // Akavache is a portable data serialization library that we'll use to // cache data that we've downloaded BlobCache.ApplicationName = "XamarinEvolveDemo"; // Set up Fusillade // // Fusillade is a super cool library that will make it so that whenever // we issue web requests, we'll only issue 4 concurrently, and if we // end up issuing multiple requests to the same resource, it will // de-dupe them. We're saying here, that we want our *backing* // HttpMessageHandler to be ModernHttpClient. Locator.CurrentMutable.RegisterConstant(new NativeMessageHandler(), typeof(HttpMessageHandler)); // CoolStuff: For routing to work, we need to tell ReactiveUI how to // create the Views associated with our ViewModels Locator.CurrentMutable.Register(() => new LoginStartView(), typeof(IViewFor <LoginStartViewModel>)); Locator.CurrentMutable.Register(() => new LoginView(), typeof(IViewFor <LoginViewModel>)); Locator.CurrentMutable.Register(() => new ChannelView(), typeof(IViewFor <ChannelViewModel>)); // Kick off to the first page of our app. If we don't navigate to a // page on startup, Xamarin Forms will get real mad (and even if it // didn't, our users would!) Router.Navigate.Execute(new LoginStartViewModel(this)); }
public LibraryViewModel(ILibraryService service = null, RoutingState router = null) { Router = router ?? Locator.Current.GetService <RoutingState>(RoutedViewHosts.Library); _service = service ?? Locator.Current.GetService <ILibraryService>(); _result = this .WhenAnyValue(x => x.Criteria) .Throttle(TimeSpan.FromMilliseconds(150)) .Select(x => x?.Trim()) .DistinctUntilChanged() .SelectMany(SearchBookAsync) .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, x => x.Result); _hasNoResult = this .WhenAnyValue(x => x.Result) .Select(x => !(x?.Any() ?? false)) .ToProperty(this, x => x.HasNoResult); this.WhenAnyValue(x => x.SelectedBook) .Where(x => x != null) .Subscribe(ViewModels => { Debug.WriteLine($"Changed book selection. {SelectedBook.Author} -- {SelectedBook.Title}"); Router.Navigate.Execute(SelectedBook); }); }
public AppBootStrapper(IMutableDependencyResolver dependencyResolver = null, RoutingState router = null) { //BlobCache.ApplicationName = Configuration.ApplicationName; Router = router ?? new RoutingState(); RegisterParts(dependencyResolver ?? Locator.CurrentMutable); Router.Navigate.Execute(new MainPageViewModel(this)); }
public AppBootstrapper() { var board = new Board(6, 4); Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); Locator.CurrentMutable.Register(() => new HighScoresPage(), typeof(IViewFor <HighScoresViewModel>)); Locator.CurrentMutable.Register(() => new HighScoresViewCell(), typeof(IViewFor <HighScoresPage>)); Locator.CurrentMutable.Register(() => new PlayPage(), typeof(IViewFor <PlayViewModel>)); Locator.CurrentMutable.Register(() => new CellView(), typeof(IViewFor <House>)); Locator.CurrentMutable.Register(() => new CellView(), typeof(IViewFor <Store>)); //Locator.CurrentMutable.Register(() => new MovieDetailView(), typeof(IViewFor<MovieDetailViewModel>)); //Locator.CurrentMutable.Register(() => new Cache(), typeof(ICache)); //Locator.CurrentMutable.Register(() => new ApiService(), typeof(IApiService)); this .Router .NavigateAndReset .Execute(new PlayViewModel()) .Subscribe(); }
public void SuccessfulLoginIntegrationTest() { var kernel = new MoqMockingKernel(); kernel.Bind <IWelcomeViewModel>().To <WelcomeViewModel>(); var cache = new TestBlobCache(null, (IEnumerable <KeyValuePair <string, byte[]> >)null); kernel.Bind <ISecureBlobCache>().ToConstant(cache); var mock = kernel.GetMock <IScreen>(); var routingState = new RoutingState(); mock.Setup(x => x.Router).Returns(routingState); var initialPage = kernel.Get <IRoutableViewModel>(); kernel.Get <IScreen>().Router.NavigateAndReset.Execute(initialPage); var fixture = kernel.Get <IWelcomeViewModel>(); kernel.Get <IScreen>().Router.Navigate.Execute(fixture); fixture.BaseUrl = IntegrationTestUrl.Current; fixture.Token = IntegrationTestUrl.Token; fixture.OkButton.Execute(null); kernel.Get <IScreen>().Router.ViewModelObservable().Skip(1) .Timeout(TimeSpan.FromSeconds(10.0), RxApp.TaskpoolScheduler) .First(); fixture.ErrorMessage.Should().BeNull(); kernel.Get <IScreen>().Router.GetCurrentViewModel().Should().Be(initialPage); }
public AppBootsrapper() { Router = new RoutingState(); ///You much register This as IScreen to represent your app's main screen Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); //We register the service in the locator Locator.CurrentMutable.Register(() => new LoginService(), typeof(ILogin)); //Register the views Locator.CurrentMutable.Register(() => new LoginPage(), typeof(IViewFor <LoginViewModel>)); Locator.CurrentMutable.Register(() => new ItemsPage(), typeof(IViewFor <ItemsViewModel>)); // Enable Framework Logging #if DEBUG Locator.CurrentMutable.RegisterConstant(new LoggingService { Level = LogLevel.Debug }, typeof(ILogger)); #endif this .Router .NavigateAndReset .Execute(new LoginViewModel(Locator.Current.GetService <ILogin>())) .Subscribe(); }
public MainViewModel() { // Initialize the Router. Router = new RoutingState(); // GoImage = ReactiveCommand.CreateFromObservable(() => Router.Navigate.Execute(new ImageViewModel())); GoVideo = ReactiveCommand.CreateFromObservable(() => Router.Navigate.Execute(new VideoViewModel())); GoNuget = ReactiveCommand.CreateFromObservable(() => Router.Navigate.Execute(new NugetViewModel())); // You can also ask the router to go back. GoBack = Router.NavigateBack; Router.Navigate.Execute(new ImageViewModel()); SomeBoolValue = false; Configuration = Locator.Current.GetService(typeof(Configuration)) as Configuration; _screens = Configuration.Screens.ToObservable() .Select(x => new ScreenListItemViewModel(x)) .ToList() .ToProperty(this, x => x.Screens); }
public WizardWindowViewModel(WizardWindow window, ApplicationStatusManager manager, SourceList <PhotoViewModel> photos, int selectedIndex) { _window = window; LocalizationContext = window.LocalizationContext; _router = new RoutingState(); _firstWizardViewModel = new FirstWizardViewModel(this, LocalizationContext); _secondWizardViewModel = new SecondWizardViewModel(this, LocalizationContext); _thirdWizardViewModel = new ThirdWizardViewModel(this, window, manager, LocalizationContext); _fourthWizardViewModel = new FourthWizardViewModel(this, manager, photos, selectedIndex, window.AppConfig, LocalizationContext); canGoNext = this .WhenAnyValue(x => x.CanGoNext); canGoBack = this. WhenAnyValue(x => x.CanGoBack); CanGoNext = true; CanGoBack = false; GoNext = ReactiveCommand.Create(Next, canGoNext); GoBack = ReactiveCommand.Create(Back, canGoBack); BackButtonText = LocalizationContext.WizardBackButtonText; NextButtonText = LocalizationContext.WizardNextButtonText; Log.Information("Wizard started."); }
public void SchedulerIsUsedForAllCommands() { var scheduler = new TestScheduler(); var fixture = new RoutingState { Scheduler = scheduler }; fixture .Navigate .ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var navigate).Subscribe(); fixture .NavigateBack .ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var navigateBack).Subscribe(); fixture .NavigateAndReset .ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var navigateAndReset).Subscribe(); fixture.Navigate.Execute(new TestViewModel()).Subscribe(); Assert.Empty(navigate); scheduler.Start(); Assert.NotEmpty(navigate); fixture.NavigateBack.Execute().Subscribe(); Assert.Empty(navigateBack); scheduler.Start(); Assert.NotEmpty(navigateBack); fixture.NavigateAndReset.Execute(new TestViewModel()).Subscribe(); Assert.Empty(navigateAndReset); scheduler.Start(); Assert.NotEmpty(navigateAndReset); }
/// <summary> /// Starts a new route to a given goal StreetConnector. /// </summary> /// <param name="goal">The goal StreetConnector</param> public void StartNewRoute(StreetConnector goal) { goalConnector = goal; if (goal == currentConnector) { currentRoutingState = RoutingState.Finished; return; } baseRoute = RouteManager.GetBestBaseRoute(currentConnector, goal); if (baseRoute == null) { specialRoute = RouteManager.GetSpecialRoute(currentConnector, goal); currentRoutingState = RoutingState.SpecialStart2; } else { if (baseRoute.Start == currentConnector) { currentRoutingState = RoutingState.BaseStart; } else { specialRoute = RouteManager.GetSpecialRoute(currentConnector, baseRoute.Start); currentRoutingState = RoutingState.SpecialStart1; } } }
public async Task NavigationPushPopTest() { var input = new TestViewModel { SomeProp = "Foo" }; var fixture = new RoutingState(); Assert.False(await fixture.NavigateBack.CanExecute.FirstAsync()); await fixture.Navigate.Execute(new TestViewModel()); Assert.Equal(1, fixture.NavigationStack.Count); Assert.False(await fixture.NavigateBack.CanExecute.FirstAsync()); await fixture.Navigate.Execute(new TestViewModel()); Assert.Equal(2, fixture.NavigationStack.Count); Assert.True(await fixture.NavigateBack.CanExecute.FirstAsync()); var navigatedTo = await fixture.NavigateBack.Execute(); if (navigatedTo is null) { throw new InvalidOperationException("Should have valid navigated to screen"); } Assert.Equal(navigatedTo.GetType(), input.GetType()); Assert.Equal(1, fixture.NavigationStack.Count); }
public void NavigationPushPopSerializationTest() { var engine = new DictionaryStorageEngine(); using (var _ = engine.AsPrimaryEngine()) { var input = new TestViewModel() { SomeProp = "Foo" }; var fixture = new RoutingState(); fixture.NavigateForward.Execute(input); RxStorage.Engine.CreateSyncPoint(fixture); var output = RxStorage.Engine.GetLatestRootObject <RoutingState>(); Assert.True(output.NavigateBack.CanExecute(null)); output.NavigateBack.Execute(null); RxStorage.Engine.CreateSyncPoint(output); output = RxStorage.Engine.GetLatestRootObject <RoutingState>(); Assert.False(output.NavigateBack.CanExecute(null)); } }
public void SuccessfulLoginIntegrationTest() { var kernel = new MoqMockingKernel(); kernel.Bind<IWelcomeViewModel>().To<WelcomeViewModel>(); var cache = new TestBlobCache(null, (IEnumerable<KeyValuePair<string, byte[]>>)null); kernel.Bind<ISecureBlobCache>().ToConstant(cache); var mock = kernel.GetMock<IScreen>(); var routingState = new RoutingState(); mock.Setup(x => x.Router).Returns(routingState); var initialPage = kernel.Get<IRoutableViewModel>(); kernel.Get<IScreen>().Router.NavigateAndReset.Execute(initialPage); var fixture = kernel.Get<IWelcomeViewModel>(); kernel.Get<IScreen>().Router.Navigate.Execute(fixture); fixture.BaseUrl = IntegrationTestUrl.Current; fixture.Token = IntegrationTestUrl.Token; fixture.OkButton.Execute(null); kernel.Get<IScreen>().Router.ViewModelObservable().Skip(1) .Timeout(TimeSpan.FromSeconds(10.0), RxApp.TaskpoolScheduler) .First(); fixture.ErrorMessage.Should().BeNull(); kernel.Get<IScreen>().Router.GetCurrentViewModel().Should().Be(initialPage); }
public AppBootstrapper() { Router = new RoutingState(); Kernel = new StandardKernel(); Kernel.Bind <TestPage1ViewModel>().ToSelf(); Kernel.Bind <TestPage2ViewModel>().ToSelf(); Kernel.Bind <TestPage3ViewModel>().ToSelf(); Kernel.Bind <IViewFor <TestPage1ViewModel> >().To <TestPage1View>(); Kernel.Bind <IViewFor <TestPage2ViewModel> >().To <TestPage2View>(); Kernel.Bind <IViewFor <TestPage3ViewModel> >().To <TestPage3View>(); Kernel.Bind <IApplicationRootState>().ToConstant(this); Kernel.Bind <IViewFor>().To <MainPage>().Named("InitialPage"); Kernel.Bind <IScreen>().ToConstant(this); RxApp.ConfigureServiceLocator( (t, s) => Kernel.Get(t, s), (t, s) => Kernel.GetAll(t, s), (c, t, s) => { var r = Kernel.Bind(t).To(c); if (s != null) { r.Named(s); } }); Router.Navigate.Execute(new TestPage1ViewModel(this)); }
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 BookViewModel(ContextViewModel vm = null, RoutingState router = null) { _contextVm = vm ?? Locator.Current.GetService <ContextViewModel>(); _router = router ?? Locator.Current.GetService <RoutingState>(RoutedViewHosts.Library); GotoContext = ReactiveCommand.CreateFromTask(GotoContextImpl); }
public void SchedulerIsUsedForAllCommands() { var scheduler = new TestScheduler(); var fixture = new RoutingState { Scheduler = scheduler }; var navigate = fixture .Navigate .CreateCollection(); var navigateBack = fixture .NavigateBack .CreateCollection(); var navigateAndReset = fixture .NavigateAndReset .CreateCollection(); fixture.Navigate.Execute(new TestViewModel()).Subscribe(); Assert.Empty(navigate); scheduler.Start(); Assert.NotEmpty(navigate); fixture.NavigateBack.Execute().Subscribe(); Assert.Empty(navigateBack); scheduler.Start(); Assert.NotEmpty(navigateBack); fixture.NavigateAndReset.Execute(new TestViewModel()).Subscribe(); Assert.Empty(navigateAndReset); scheduler.Start(); Assert.NotEmpty(navigateAndReset); }
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(); 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 AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); Locator.CurrentMutable.Register(() => new MainView(), typeof(IViewFor <MainViewModel>)); Locator.CurrentMutable.Register(() => new MenuView(), typeof(IViewFor <MenuViewModel>)); Locator.CurrentMutable.RegisterConstant(new BoardContainer(), typeof(IBoardContainer)); Locator.CurrentMutable.Register(() => new GameLostChecker(), typeof(IGameLostChecker)); Locator.CurrentMutable.Register(() => new SquareSpawner(), typeof(ISquareSpawner)); Locator.CurrentMutable.Register(() => new SquareTranslator(), typeof(ISquareTranslator)); Locator.CurrentMutable.Register(() => new DragReader(), typeof(IDragReader)); Locator.CurrentMutable.Register(() => new ScoreReader(), typeof(IScoreReader)); Locator.CurrentMutable.Register(() => new ScoreSaver(), typeof(IScoreSaver)); this .Router .NavigateAndReset .Execute(new MenuViewModel()) .Subscribe(); }
public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); // Set up Akavache // // Akavache is a portable data serialization library that we'll use to // cache data that we've downloaded BlobCache.ApplicationName = "XamarinEvolveDemo"; // Set up Fusillade // // Fusillade is a super cool library that will make it so that whenever // we issue web requests, we'll only issue 4 concurrently, and if we // end up issuing multiple requests to the same resource, it will // de-dupe them. We're saying here, that we want our *backing* // HttpMessageHandler to be ModernHttpClient. Locator.CurrentMutable.RegisterConstant(new NativeMessageHandler(), typeof(HttpMessageHandler)); // CoolStuff: For routing to work, we need to tell ReactiveUI how to // create the Views associated with our ViewModels Locator.CurrentMutable.Register(() => new LoginStartView(), typeof(IViewFor<LoginStartViewModel>)); Locator.CurrentMutable.Register(() => new LoginView(), typeof(IViewFor<LoginViewModel>)); Locator.CurrentMutable.Register(() => new ChannelView(), typeof(IViewFor<ChannelViewModel>)); // Kick off to the first page of our app. If we don't navigate to a // page on startup, Xamarin Forms will get real mad (and even if it // didn't, our users would!) Router.Navigate.Execute(new LoginStartViewModel(this)); }
public void TheTimerShouldFireIfPusherDoesnt() { (new TestScheduler()).With(sched => { var kernel = new MoqMockingKernel(); var router = new RoutingState(); var pusher = new Subject <Unit>(); int nowPlayingExecuteCount = 0; var fixture = setupStandardMock(kernel, router, () => { kernel.GetMock <IPlayApi>().Setup(x => x.ConnectToSongChangeNotifications()).Returns(pusher); kernel.GetMock <IPlayApi>().Setup(x => x.NowPlaying()) .Callback(() => nowPlayingExecuteCount++).Returns(Observable.Return(Fakes.GetSong())); }); router.Navigate.Execute(fixture); sched.AdvanceToMs(10); nowPlayingExecuteCount.Should().Be(1); sched.AdvanceToMs(1000); nowPlayingExecuteCount.Should().Be(1); pusher.OnNext(Unit.Default); sched.AdvanceToMs(1010); nowPlayingExecuteCount.Should().Be(2); // NB: The 2 minute timer starts after the last Pusher notification // make sure we *don't* tick. sched.AdvanceToMs(2 * 60 * 1000 + 10); nowPlayingExecuteCount.Should().Be(2); sched.AdvanceToMs(3 * 60 * 1000 + 1500); nowPlayingExecuteCount.Should().Be(3); }); }
public void AppStateShouldBeSetOnRepairClicked() { var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); IRoutableViewModel latestVm = null; var fixture = setupStandardFixture(router, kernel, () => { var branchInfo = new Dictionary<string, HeuristicTreeInformation>() { { "Working Directory", new HeuristicTreeInformation("derp", true)} }; kernel.Get<IRepoAnalysisProvider>().AnalyzeRepo(null) .ReturnsForAnyArgs(Observable.Return(Tuple.Create("foo", branchInfo))); router.ViewModelObservable().Subscribe(x => latestVm = x); }); fixture.AnalyzeRepo.Execute("foo"); fixture.RepairButtonVisibility.ShouldEqual(Visibility.Visible); fixture.RepairButton.Execute(null); var result = kernel.Get<IAppState>(); (latestVm is IRepairViewModel).ShouldBeTrue(); result.CurrentRepo.ShouldEqual("foo"); result.BranchInformation.ShouldNotBeNull(); }
public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); Locator.CurrentMutable.RegisterLazySingleton(() => new NativeMessageHandler(), typeof(HttpMessageHandler)); Locator.CurrentMutable.Register(() => new LoginPage(), typeof(IViewFor <LoginViewModel>)); Locator.CurrentMutable.Register(() => new RoomsPage(), typeof(IViewFor <RoomsViewModel>)); //Locator.CurrentMutable.Register(() => new MessagesPage(), typeof(IViewFor<MessagesViewModel>)); LoginInfo loginInfo = BlobCache.Secure.GetLoginAsync("Gitter") .Catch <LoginInfo, KeyNotFoundException>(ex => Observable.Return((LoginInfo)null)) .Wait(); if (loginInfo == null) { this.Router.Navigate.Execute(new LoginViewModel()); } else { this.Router.Navigate.Execute(new RoomsViewModel()); } }
public AppBotstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); // Set up Akavache // // Akavache is a portable data serialization library that we'll use to // cache data that we've downloaded BlobCache.ApplicationName = "Restaurant"; // Set up Fusillade // // Fusillade is a super cool library that will make it so that whenever // we issue web requests, we'll only issue 4 concurrently, and if we // end up issuing multiple requests to the same resource, it will // de-dupe them. We're saying here, that we want our *backing* // HttpMessageHandler to be ModernHttpClient. Locator.CurrentMutable.RegisterConstant(new NativeMessageHandler(), typeof(HttpMessageHandler)); Locator.CurrentMutable.Register(() => new LoginView(), typeof(IViewFor<LoginViewModel>)); Locator.CurrentMutable.Register(() => new RegesterView(), typeof(IViewFor<RegesterViewModel>)); Router.Navigate.Execute(new LoginViewModel(this)); }
public MainViewModel( Func<ExerciseProgramsViewModel> exerciseProgramsViewModelFactory) { exerciseProgramsViewModelFactory.AssertNotNull(nameof(exerciseProgramsViewModelFactory)); this.router = new RoutingState(); this.exerciseProgramsViewModelFactory = exerciseProgramsViewModelFactory; }
public MainViewModel( Func<ExerciseProgramsViewModel> exerciseProgramsViewModelFactory) { Ensure.ArgumentNotNull(exerciseProgramsViewModelFactory, nameof(exerciseProgramsViewModelFactory)); this.router = new RoutingState(); this.exerciseProgramsViewModelFactory = exerciseProgramsViewModelFactory; }
public void ANewSetupInstallerWillTriggerTheOldInstallerToUninstall() { string dir, targetRootDirectory; using (Utility.WithTempDirectory(out targetRootDirectory)) { var firstVersionDirectory = Path.Combine(targetRootDirectory, "SampleUpdatingApp", "app-1.0.0.0"); var secondVersionDirectory = Path.Combine(targetRootDirectory, "SampleUpdatingApp", "app-1.1.0.0"); using (IntegrationTestHelper.WithFakeInstallDirectory("SampleUpdatingApp.1.0.0.0.nupkg", out dir)) { // install version 1 mockPerformInstall(dir, targetRootDirectory); Assert.True(Directory.Exists(firstVersionDirectory)); } using (IntegrationTestHelper.WithFakeInstallDirectory("SampleUpdatingApp.1.1.0.0.nupkg", out dir)) { // install version 1.1 mockPerformInstall(dir, targetRootDirectory); Assert.True(Directory.Exists(firstVersionDirectory)); Assert.True(Directory.Exists(secondVersionDirectory)); } using (IntegrationTestHelper.WithFakeInstallDirectory("SampleUpdatingApp.1.0.0.0.nupkg", out dir)) { // uninstall version 1.0 var kernel = new TinyIoCContainer(); kernel.Register(Mock.Of<IProcessFactory>()); var router = new RoutingState(); var detectPackage = new Subject<DetectPackageCompleteEventArgs>(); var planComplete = new Subject<PlanCompleteEventArgs>(); var applyComplete = new Subject<ApplyCompleteEventArgs>(); var error = new Subject<ErrorEventArgs>(); var engine = new Mock<IEngine>(); var events = new Mock<IWiXEvents>(); events.SetupGet(x => x.DetectPackageCompleteObs).Returns(detectPackage); events.SetupGet(x => x.ErrorObs).Returns(error); events.SetupGet(x => x.PlanCompleteObs).Returns(planComplete); events.SetupGet(x => x.ApplyCompleteObs).Returns(applyComplete); events.SetupGet(x => x.Engine).Returns(engine.Object); events.SetupGet(x => x.DisplayMode).Returns(Display.Embedded); events.SetupGet(x => x.Action).Returns(LaunchAction.Uninstall); var firstUninstallFixture = new WixUiBootstrapper(events.Object, kernel, router, null, dir, targetRootDirectory); mockPerformUninstall(detectPackage, planComplete, applyComplete, engine); Assert.False(Directory.Exists(firstVersionDirectory), "The old version is not cleaned up as expected"); Assert.True(Directory.Exists(secondVersionDirectory), "The new version should persist after uninstalling the old version"); } } }
public Shell() { ConfigIoc(); InitializeComponent(); Router = new RoutingState(); ViewHost.Router = Router; ViewHost.Router.Navigate.Go<MainWindowViewModel>(); }
public void WhenRoutedToViewModelItShouldAddViewToControls() { var viewLocator = new FakeViewLocator { LocatorFunc = t => new FakeWinformsView() }; var router = new RoutingState(); var target = new WinFormsRoutedViewHost { Router = router, ViewLocator = viewLocator }; router.Navigate.Execute(new FakeWinformViewModel()); Assert.Equal(1, target.Controls.OfType<FakeWinformsView>().Count()); }
// ctor /// <summary> /// Initializes a new instance of the <see cref="AppModel" /> class. /// </summary> /// <param name="platform">The platform.</param> public AppModel(IPlatform platform) { Platform = platform; DataManager = new DataManager(platform); Router = new RoutingState(); ViewModelPool = new Dictionary<string, Tuple<IRoutableViewModel, IRoutingParams>>(); _subscriptions = new Dictionary<string, IDisposable>(); //Init(); => Call after Activity is created because RxApp.MainThreadScheduler must be set }
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 Bootstrapper(IMutableDependencyResolver deps = null, RoutingState testRouter = null) { Router = testRouter ?? new RoutingState(); deps = deps ?? Locator.CurrentMutable; var options = ((App) System.Windows.Application.Current).CommandLineOptions; // Bind RegisterParts(deps); // This is a good place to set up any other app // startup tasks, like setting the logging level LogHost.Default.Level = LogLevel.Debug; var settingsManager = deps.GetService<ISettingsManager>(); var gameManager = deps.GetService<IGameManager>(); deps.GetService<NLog.ILogger>().Info("Waiting for settings..."); settingsManager.ApiAuthenticated.Subscribe(user => { if (user != null) { ((App)System.Windows.Application.Current).CrashManager.SetUser(user); } }); // Navigate to the opening page of the application settingsManager.SettingsAvailable.Subscribe(settings => { if (settings == null) { return; } System.Windows.Application.Current.Dispatcher.Invoke(delegate { deps.GetService<NLog.ILogger>().Info("Got settings!"); if (settings.IsFirstRun || string.IsNullOrEmpty(settings.ApiKey)) { System.Windows.Application.Current.MainWindow = new MainWindow(this); System.Windows.Application.Current.MainWindow.Show(); Router.Navigate.Execute(new SettingsViewModel(this, deps.GetService<ISettingsManager>(), deps.GetService<IVersionManager>(), deps.GetService<IGameManager>()) ); } else if (!options.Minimized) { // start the initialization gameManager.Initialize(); System.Windows.Application.Current.MainWindow = new MainWindow(this); System.Windows.Application.Current.MainWindow.Show(); Router.Navigate.Execute(new MainViewModel(this, deps.GetService<ISettingsManager>(), deps.GetService<IVersionManager>())); } else { // start the initialization gameManager.Initialize(); } }); }); }
public AppBootstrap() { Router = new RoutingState(); var resolver = RxApp.MutableResolver; resolver.RegisterConstant(this, typeof(IScreen)); resolver.Register(() => new LoginRouteView(), typeof(IViewFor<LoginRouteViewModel>)); resolver.Register(() => new PersonListView(), typeof(IViewFor<PersonListViewModel>)); resolver.Register(() => new PersonAddView(), typeof(IViewFor<PersonAddViewModel>)); Router.Navigate.Execute(new LoginRouteViewModel(this)); }
public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); Locator.CurrentMutable.Register(() => new TestView(), typeof(IViewFor<TestViewModel>)); Locator.CurrentMutable.Register(() => new DifferentView(), typeof(IViewFor<DifferentViewModel>)); Router.Navigate.Execute(new TestViewModel(this)); // Router.NavigationStack.Add(new TestViewModel(this)); }
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(); }
public void ShouldSetDefaultContentWhenViewModelIsNull() { var defaultContent = new Control(); var viewLocator = new FakeViewLocator { LocatorFunc = t => new FakeWinformsView() }; var router = new RoutingState(); var target = new WinFormsRoutedViewHost { Router = router, ViewLocator = viewLocator, DefaultContent = defaultContent }; Assert.True(target.Controls.Contains(defaultContent)); }
public MainWindowViewModel() { Router = new RoutingState(); var canAdd = this.WhenAnyValue(vm => vm.Router.NavigationStack.Count).Select(count => count == 0); AddCommand = new ReactiveCommand(canAdd); AddCommand.Subscribe(_ => Router.Navigate.Execute(new CustomViewModel(this) { SomeValue = "Trololol" })); var canReset = this.WhenAnyValue(vm => vm.Router.NavigationStack.Count).Select(count => count > 0); ResetCommand = new ReactiveCommand(canReset); ResetCommand.Subscribe(_ => Router.NavigateBack.Execute(null)); }
public AppBootstrapper(IMutableDependencyResolver dependencyResolver = null, RoutingState testRouter = null) { Router = testRouter ?? new RoutingState(); dependencyResolver = dependencyResolver ?? Locator.CurrentMutable; // Bind RegisterParts(dependencyResolver); // TODO: This is a good place to set up any other app // startup tasks, like setting the logging level LogHost.Default.Level = LogLevel.Debug; // Navigate to the opening page of the application Router.Navigate.Execute(new WelcomeViewModel(this)); }
public MainWindowViewModel() { Router = new RoutingState(); var canGoBack = this.WhenAnyValue(vm => vm.Router.NavigationStack.Count) .Select(count => count > 0); NavigateToACommand = ReactiveCommand.Create(); NavigateToBCommand = ReactiveCommand.Create(); BackCommand = ReactiveCommand.Create(canGoBack); NavigateToACommand.Subscribe(NavigateToA); NavigateToBCommand.Subscribe(NavigateToB); BackCommand.Subscribe(NavigateBack); }
public void AnalyzeRepoWithThingsThatArentReposShouldFail(string input) { var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); UserError error = null; var fixture = setupStandardFixture(router, kernel, () => kernel.Bind<IRepoAnalysisProvider>().To<RepoAnalysisProvider>()); using(UserError.OverrideHandlersForTesting(x => { error = x; return RecoveryOptionResult.CancelOperation; })) { fixture.AnalyzeRepo.Execute(input); } error.ShouldNotBeNull(); fixture.RepairButtonVisibility.ShouldNotEqual(Visibility.Visible); }
public void NavigationPushPopTest() { var input = new TestViewModel() {SomeProp = "Foo"}; var fixture = new RoutingState(); Assert.False(fixture.NavigateBack.CanExecute(input)); fixture.Navigate.Execute(input); Assert.Equal(1, fixture.NavigationStack.Count); Assert.True(fixture.NavigateBack.CanExecute(null)); fixture.NavigateBack.Execute(null); Assert.Equal(0, fixture.NavigationStack.Count); }
public AppBootstrapper(IMutableDependencyResolver dependencyResolver = null, RoutingState testRouter = null) { Router = testRouter ?? new RoutingState(); dependencyResolver = dependencyResolver ?? Locator.CurrentMutable; // Bind RegisterParts(dependencyResolver); // TODO: This is a good place to set up any other app // startup tasks, like setting the logging level #if DEBUG LogHost.Default.Level = LogLevel.Debug; #else LogHost.Default.Level = LogLevel.Info; #endif }
public void ShouldDisposePreviousView() { var viewLocator = new FakeViewLocator { LocatorFunc = t => new FakeWinformsView() }; var router = new RoutingState(); var target = new WinFormsRoutedViewHost { Router = router, ViewLocator = viewLocator }; router.Navigate.Execute(new FakeWinformViewModel()); FakeWinformsView currentView = target.Controls.OfType<FakeWinformsView>().Single(); bool isDisposed = false; currentView.Disposed += (o, e) => isDisposed = true; // switch the viewmodel router.Navigate.Execute(new FakeWinformViewModel()); Assert.True(isDisposed); }
public void RoutingStateSerializableRoundTripTest() { var engine = new DictionaryStorageEngine(); using(var _ = engine.AsPrimaryEngine()) { var input = new TestViewModel() {SomeProp = "Foo"}; var fixture = new RoutingState(); fixture.NavigationStack.Add(input); RxStorage.Engine.CreateSyncPoint(fixture); var output = RxStorage.Engine.Load<RoutingState>(fixture.ContentHash); Assert.True(output.NavigationStack.Count == 1); Assert.True(output.NavigationStack[0].ContentHash == input.ContentHash); Assert.Equal(input.SomeProp, ((TestViewModel) output.NavigationStack[0]).SomeProp); } }
public void NavigatingToPlayWithoutAPasswordShouldNavigateToLogin() { var kernel = new MoqMockingKernel(); kernel.Bind<IPlayViewModel>().To<PlayViewModel>(); var cache = new TestBlobCache(null, (IEnumerable<KeyValuePair<string, byte[]>>)null); kernel.Bind<ISecureBlobCache>().ToConstant(cache); kernel.GetMock<ILoginMethods>() .Setup(x => x.EraseCredentialsAndNavigateToLogin()).Verifiable(); var router = new RoutingState(); kernel.GetMock<IScreen>().Setup(x => x.Router).Returns(router); var fixture = kernel.Get<IPlayViewModel>(); router.Navigate.Execute(fixture); kernel.GetMock<ILoginMethods>().Verify(x => x.EraseCredentialsAndNavigateToLogin(), Times.Once()); }
public void CurrentViewModelObservableIsAccurate() { var fixture = new RoutingState(); var output = fixture.CurrentViewModel.CreateCollection(); Assert.Equal(1, output.Count); fixture.Navigate.Execute(new TestViewModel() { SomeProp = "A" }); Assert.Equal(2, output.Count); fixture.Navigate.Execute(new TestViewModel() { SomeProp = "B" }); Assert.Equal(3, output.Count); Assert.Equal("B", ((TestViewModel)output.Last()).SomeProp); fixture.NavigateBack.Execute(null); Assert.Equal(4, output.Count); Assert.Equal("A", ((TestViewModel)output.Last()).SomeProp); }