Пример #1
0
        public void ConnectCommand_InvokedForStandard_ShouldLogin()
        {
            _sut.Initialize();

            _sut.IsEnterprise = false;
            _sut.Login        = Guid.NewGuid().ToString();
            _sut.Password     = Guid.NewGuid().ToString();

            var result = _gitClientService
                         .Capture()
                         .Args <GitCredentials>((s, repo) => s.LoginAsync(repo));

            _sut.ConnectCommand.Execute(null);

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.AreEqual(_sut.Login, args.Login);
            Assert.AreEqual(_sut.Password, args.Password);
            Assert.AreEqual(null, args.Host);
            Assert.AreEqual(_sut.IsEnterprise, args.IsEnterprise);

            _gitClientService.VerifyAllExpectations();
        }
Пример #2
0
        public void CreateCommand_Invoked_ShouldCreateRepositoryAndCloneAndRaiseClosed()
        {
            bool closed = false;

            _sut.Name      = "repo";
            _sut.LocalPath = "path";
            _sut.IsPrivate = true;
            _sut.Closed   += delegate { closed = true; };

            var remoteRepo = new GitRemoteRepository()
            {
                CloneUrl = Guid.NewGuid().ToString(),
                Name     = Guid.NewGuid().ToString()
            };

            _gitService.Expect(x => x.CloneRepository(remoteRepo.CloneUrl, remoteRepo.Name, _sut.LocalPath));

            var result = _gitClientService
                         .Capture()
                         .Args <GitRemoteRepository, GitRemoteRepository>((s, repo) => s.CreateRepositoryAsync(repo), remoteRepo);

            _sut.CreateCommand.Execute(null);

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.AreEqual(_sut.Name, args.Name);
            Assert.AreEqual(_sut.Description, args.Description);
            Assert.AreEqual(_sut.IsPrivate, args.IsPrivate);

            _gitClientService.VerifyAllExpectations();
            _gitService.VerifyAllExpectations();
            Assert.That(closed, Is.EqualTo(true));
        }
Пример #3
0
        public void Initialize_SecondTime_ShouldntReinitializePullRequests()
        {
            Initialize_LoadNextPageAfterInitialization_ShouldLoadExpectedPullRequests();

            _sut.InitializeCommand.Execute(null);

            _gitClientService.VerifyAllExpectations();
        }
Пример #4
0
        public void LogoutCommand_ShouldLogoutGitClient()
        {
            _gitClientService.Expect(x => x.Logout()).Repeat.Once();

            var sut = CreateSut();

            sut.LogoutCommand.Execute(null);

            _gitClientService.VerifyAllExpectations();
        }
        public void PublishCommand_Invoked_ShouldCreateAndPublishRepositoryAndRefreshActiveRepo()
        {
            IEnumerable <GitTeam> teams = new List <GitTeam>()
            {
                new GitTeam()
                {
                    Name = "TeamName"
                }
            };
            var connectionData = new ConnectionData()
            {
                UserName = "******", IsLoggedIn = true
            };

            _gitClientService.Expect(x => x.GetTeams()).Return(teams.FromTaskAsync());
            _userInfoService.Stub(x => x.ConnectionData).Return(connectionData);

            _sut.Initialize();


            var remoteRepo = new GitRemoteRepository();

            _sut.SelectedOwner = new Owner()
            {
                Name = "owner"
            };
            _sut.RepositoryName = "repoName with space";
            _sut.Description    = "description";
            _sut.IsPrivate      = true;

            _gitService.Expect(x => x.PublishRepository(remoteRepo));
            _gitWatcher.Expect(x => x.Refresh());

            var result = _gitClientService
                         .Capture()
                         .Args <GitRemoteRepository, GitRemoteRepository>((s, repo) => s.CreateRepositoryAsync(repo), remoteRepo);

            _sut.PublishRepositoryCommand.Execute(null);

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.AreEqual("repoName-with-space", args.Name);
            Assert.AreEqual(_sut.Description, args.Description);
            Assert.AreEqual(_sut.IsPrivate, args.IsPrivate);
            Assert.AreEqual(_sut.SelectedOwner, args.Owner);

            _gitClientService.VerifyAllExpectations();
            _gitService.VerifyAllExpectations();
            _gitWatcher.VerifyAllExpectations();
        }
        public void Initialize_GetPullRequestForBranchesThrowsException_ShouldSetErrorMessage()
        {
            var remoteBranches   = GetRemoteBranches();
            var activeRepository = GetActiveRepo();

            _gitService.Expect(x => x.GetActiveRepository()).Return(activeRepository);
            _gitClientService.Expect(x => x.GetBranches()).Return(remoteBranches.FromTaskAsync());

            _gitClientService
            .Expect(x => x.GetPullRequestForBranches(Arg <string> .Is.Anything, Arg <string> .Is.Anything))
            .Throw(new Exception());

            _sut.ErrorMessage = null;

            _sut.Initialize();

            _gitClientService.VerifyAllExpectations();
            Assert.IsNotNull(_sut.ErrorMessage);
        }