Esempio n. 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();
        }
Esempio n. 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));
        }
        public void CreatePullRequest_PullRequestDoesntExist_ShouldCreatePullRequestAndNavigateBack()
        {
            _sut.RemotePullRequest = null;
            _sut.Title             = Guid.NewGuid().ToString();
            _sut.Description       = Guid.NewGuid().ToString();
            _sut.SourceBranch      = new GitBranch()
            {
                Name = Guid.NewGuid().ToString()
            };
            _sut.DestinationBranch = new GitBranch()
            {
                Name = Guid.NewGuid().ToString()
            };
            _sut.CloseSourceBranch = true;
            _sut.SelectedReviewers = new ReactiveList <GitUser>()
            {
                new GitUser()
                {
                    Username = "******"
                }, new GitUser()
                {
                    Username = "******"
                }
            };

            _pageNavigationService.Expect(x => x.NavigateBack(true));

            var result = _gitClientService
                         .Capture()
                         .Args <GitPullRequest>((s, pullRequest) => s.CreatePullRequest(pullRequest));

            _sut.CreateNewPullRequestCommand.Execute(null);

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.AreEqual(0, args.Id);
            Assert.AreEqual(_sut.Title, args.Title);
            Assert.AreEqual(_sut.Description, args.Description);
            Assert.AreEqual(_sut.SourceBranch.Name, args.SourceBranch.Name);
            Assert.AreEqual(_sut.DestinationBranch.Name, args.DestinationBranch.Name);
            Assert.AreEqual(_sut.CloseSourceBranch, args.CloseSourceBranch);
            Assert.AreEqual(_sut.SelectedReviewers.Count, args.Reviewers.Count);

            _pageNavigationService.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();
        }