Ejemplo n.º 1
0
        public void WithMultipleCallsDoesNotThrowException()
        {
            var uiProvider   = Substitute.For <IUIProvider>();
            var hosts        = Substitute.For <IRepositoryHosts>();
            var factory      = Substitute.For <IExportFactoryProvider>();
            var cm           = Substitutes.ConnectionManager;
            var uiController = new UIController(uiProvider, hosts, factory, cm, LazySubstitute.For <ITwoFactorChallengeHandler>());

            uiController.Dispose();
            uiController.Dispose();
        }
Ejemplo n.º 2
0
        public void ShowingCloneDialogWhenLoggedInShowsCloneDialog()
        {
            var provider   = Substitutes.GetFullyMockedServiceProvider();
            var hosts      = provider.GetRepositoryHosts();
            var factory    = SetupFactory(provider);
            var connection = provider.GetConnection();

            connection.Login().Returns(Observable.Return(connection));
            var cm = provider.GetConnectionManager();

            cm.Connections.Returns(new ObservableCollection <IConnection> {
                connection
            });
            var host = hosts.GitHubHost;

            hosts.LookupHost(connection.HostAddress).Returns(host);
            host.IsLoggedIn.Returns(true);

            using (var uiController = new UIController((IUIProvider)provider, hosts, factory, cm, LazySubstitute.For <ITwoFactorChallengeHandler>()))
            {
                var list = new List <IView>();
                uiController.SelectFlow(UIControllerFlow.Clone)
                .Subscribe(uc => list.Add(uc as IView),
                           () =>
                {
                    Assert.Equal(1, list.Count);
                    Assert.IsAssignableFrom <IViewFor <IRepositoryCloneViewModel> >(list[0]);
                });
                uiController.Start(connection);
            }
        }
Ejemplo n.º 3
0
        public void ShowingCloneDialogWithoutBeingLoggedInShowsLoginDialog()
        {
            var provider  = Substitutes.GetFullyMockedServiceProvider();
            var hosts     = provider.GetRepositoryHosts();
            var factory   = SetupFactory(provider);
            var loginView = factory.GetView(GitHub.Exports.UIViewType.Login);

            loginView.Value.Cancel.Returns(Observable.Empty <object>());
            var cm = provider.GetConnectionManager();

            cm.Connections.Returns(new ObservableCollection <IConnection>());

            using (var uiController = new UIController((IUIProvider)provider, hosts, factory, cm, LazySubstitute.For <ITwoFactorChallengeHandler>()))
            {
                var list = new List <IView>();
                uiController.SelectFlow(UIControllerFlow.Clone)
                .Subscribe(uc => list.Add(uc as IView),
                           () =>
                {
                    Assert.True(list.Count > 1);
                    Assert.IsAssignableFrom <IViewFor <ILoginControlViewModel> >(list[0]);
                });

                uiController.Start(null);
            }
        }