protected void SetupViewModel <VM>(IExportFactoryProvider factory, GitHub.Exports.UIViewType type) where VM : class, IViewModel { var v = Substitute.For <VM, INotifyPropertyChanged>(); var e = new ExportLifetimeContext <IViewModel>(v, () => { }); factory.GetViewModel(type).Returns(e); }
protected void SetupView <VM>(IExportFactoryProvider factory, GitHub.Exports.UIViewType type) where VM : class, IViewModel { var view = Substitute.For <IView, IViewFor <VM> >(); var viewModel = factory.GetViewModel(type).Value; view.ViewModel.Returns(viewModel); var e = new ExportLifetimeContext <IView>(view, () => { }); factory.GetView(type).Returns(e); }
protected void SetupViewModel <VM>(IExportFactoryProvider factory, GitHub.Exports.UIViewType type) where VM : class, IViewModel { var v = Substitute.For <IDialogViewModel, VM, INotifyPropertyChanged>(); var done = new ReplaySubject <Unit>(); var cancel = ReactiveCommand.Create(); v.Done.Returns(_ => done); v.Cancel.Returns(cancel); ((IHasCancel)v).Cancel.Returns(cancel.SelectUnit()); var e = new ExportLifetimeContext <IViewModel>(v, () => { }); factory.GetViewModel(type).Returns(e); }
protected void SetupView <VM>(IExportFactoryProvider factory, GitHub.Exports.UIViewType type) where VM : class, IViewModel { IView view; //if (type == GitHub.Exports.UIViewType.PRList) // view = Substitutes.For<IView, IViewFor<VM>, IHasCreationView, IHasDetailView>(); //else view = Substitute.For <IView, IViewFor <VM> >(); view.Done.Returns(new ReplaySubject <ViewWithData>()); view.Cancel.Returns(new ReplaySubject <ViewWithData>()); //(view as IHasDetailView)?.Open.Returns(new ReplaySubject<ViewWithData>()); //(view as IHasCreationView)?.Create.Returns(new ReplaySubject<ViewWithData>()); var e = new ExportLifetimeContext <IView>(view, () => { }); factory.GetView(type).Returns(e); }
public UIController(IUIProvider uiProvider, IRepositoryHosts hosts, IExportFactoryProvider factory, IConnectionManager connectionManager, Lazy<ITwoFactorChallengeHandler> lazyTwoFactorChallengeHandler) { this.factory = factory; this.uiProvider = uiProvider; this.hosts = hosts; this.connectionManager = connectionManager; this.lazyTwoFactorChallengeHandler = lazyTwoFactorChallengeHandler; #if DEBUG if (Application.Current != null && !Splat.ModeDetector.InUnitTestRunner()) { var waitDispatcher = RxApp.MainThreadScheduler as WaitForDispatcherScheduler; if (waitDispatcher != null) { Debug.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher, "DispatcherScheduler is set correctly"); } else { Debug.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher, "The MainThreadScheduler is using the wrong dispatcher"); } } #endif machine = new StateMachine<UIViewType, Trigger>(UIViewType.None); machine.Configure(UIViewType.Login) .OnEntry(() => { RunView(UIViewType.Login); }) .Permit(Trigger.Next, UIViewType.TwoFactor) // Added the following line to make it easy to login to both GitHub and GitHub Enterprise // in DesignTimeStyleHelper in order to test Publish. .Permit(Trigger.Cancel, UIViewType.End) .PermitIf(Trigger.Finish, UIViewType.End, () => currentFlow == UIControllerFlow.Authentication) .PermitIf(Trigger.Finish, UIViewType.Create, () => currentFlow == UIControllerFlow.Create) .PermitIf(Trigger.Finish, UIViewType.Clone, () => currentFlow == UIControllerFlow.Clone) .PermitIf(Trigger.Finish, UIViewType.Publish, () => currentFlow == UIControllerFlow.Publish); machine.Configure(UIViewType.TwoFactor) .SubstateOf(UIViewType.Login) .OnEntry(() => { RunView(UIViewType.TwoFactor); }) .Permit(Trigger.Cancel, UIViewType.End) .PermitIf(Trigger.Next, UIViewType.End, () => currentFlow == UIControllerFlow.Authentication) .PermitIf(Trigger.Next, UIViewType.Create, () => currentFlow == UIControllerFlow.Create) .PermitIf(Trigger.Next, UIViewType.Clone, () => currentFlow == UIControllerFlow.Clone) .PermitIf(Trigger.Next, UIViewType.Publish, () => currentFlow == UIControllerFlow.Publish); machine.Configure(UIViewType.Create) .OnEntry(() => { RunView(UIViewType.Create); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.Clone) .OnEntry(() => { RunView(UIViewType.Clone); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.Publish) .OnEntry(() => { RunView(UIViewType.Publish); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.End) .OnEntry(() => { uiProvider.RemoveService(typeof(IConnection)); transition.OnCompleted(); }) .Permit(Trigger.Next, UIViewType.Finished); // it might be useful later to check which triggered // made us enter here (Cancel or Next) and set a final // result accordingly, which is why UIViewType.End only // allows a Next trigger machine.Configure(UIViewType.Finished); }
public UIFactory(IExportFactoryProvider factory) { this.factory = factory; }
public UIController(IUIProvider uiProvider, IRepositoryHosts hosts, IExportFactoryProvider factory, IConnectionManager connectionManager, Lazy <ITwoFactorChallengeHandler> lazyTwoFactorChallengeHandler) { this.factory = factory; this.uiProvider = uiProvider; this.hosts = hosts; this.connectionManager = connectionManager; this.lazyTwoFactorChallengeHandler = lazyTwoFactorChallengeHandler; #if DEBUG if (Application.Current != null && !Splat.ModeDetector.InUnitTestRunner()) { var waitDispatcher = RxApp.MainThreadScheduler as WaitForDispatcherScheduler; if (waitDispatcher != null) { Debug.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher, "DispatcherScheduler is set correctly"); } else { Debug.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher, "The MainThreadScheduler is using the wrong dispatcher"); } } #endif machine = new StateMachine <UIViewType, Trigger>(UIViewType.None); machine.Configure(UIViewType.Login) .OnEntry(() => { RunView(UIViewType.Login); }) .Permit(Trigger.Next, UIViewType.TwoFactor) // Added the following line to make it easy to login to both GitHub and GitHub Enterprise // in DesignTimeStyleHelper in order to test Publish. .Permit(Trigger.Cancel, UIViewType.End) .PermitIf(Trigger.Finish, UIViewType.End, () => currentFlow == UIControllerFlow.Authentication) .PermitIf(Trigger.Finish, UIViewType.Create, () => currentFlow == UIControllerFlow.Create) .PermitIf(Trigger.Finish, UIViewType.Clone, () => currentFlow == UIControllerFlow.Clone) .PermitIf(Trigger.Finish, UIViewType.Publish, () => currentFlow == UIControllerFlow.Publish); machine.Configure(UIViewType.TwoFactor) .SubstateOf(UIViewType.Login) .OnEntry(() => { RunView(UIViewType.TwoFactor); }) .Permit(Trigger.Cancel, UIViewType.End) .PermitIf(Trigger.Next, UIViewType.End, () => currentFlow == UIControllerFlow.Authentication) .PermitIf(Trigger.Next, UIViewType.Create, () => currentFlow == UIControllerFlow.Create) .PermitIf(Trigger.Next, UIViewType.Clone, () => currentFlow == UIControllerFlow.Clone) .PermitIf(Trigger.Next, UIViewType.Publish, () => currentFlow == UIControllerFlow.Publish); machine.Configure(UIViewType.Create) .OnEntry(() => { RunView(UIViewType.Create); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.Clone) .OnEntry(() => { RunView(UIViewType.Clone); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.Publish) .OnEntry(() => { RunView(UIViewType.Publish); }) .Permit(Trigger.Cancel, UIViewType.End) .Permit(Trigger.Next, UIViewType.End); machine.Configure(UIViewType.End) .OnEntry(() => { uiProvider.RemoveService(typeof(IConnection)); transition.OnCompleted(); }) .Permit(Trigger.Next, UIViewType.Finished); // it might be useful later to check which triggered // made us enter here (Cancel or Next) and set a final // result accordingly, which is why UIViewType.End only // allows a Next trigger machine.Configure(UIViewType.Finished); }
public UIFactory(IExportFactoryProvider factory) { this.factory = factory; }