Exemple #1
0
        public void GetBuilds_Branch_Succeeds()
        {
            VstsConfig vstsConfig = GetVstsConfig();

            IHttpClient      httpClient    = new HttpClient();
            ITokenRepository repository    = new JsonFileTokenRepository(new FileSystem());
            IAuthenticator   authenticator = new VstsOAuthAuthenticator(httpClient, repository, vstsConfig);

            File.Copy($"..//..//..//testdata//{TokenFilename}", fullTokenFilename, true);

            AuthenticationResult authResult = authenticator.Authenticate();

            File.Copy(fullTokenFilename, $"..//..//..//testdata//{TokenFilename}", true);

            this.sut = new VstsSyncReleaseClient(vstsConfig);

            IEnumerable <Build> result =
                this.sut.GetBuilds(
                    1, authResult.AccessToken, branch: "refs/heads/master");

            Assert.NotNull(result);
            Assert.True(result.Count() > 0);

            SaveResultData(result, "../../../testdata/GetBuilds_Branch.json");
        }
Exemple #2
0
        public void UpdateReleaseEnvironment_Succeeds()
        {
            VstsConfig vstsConfig = GetVstsConfig();

            IHttpClient      httpClient    = new HttpClient();
            ITokenRepository repository    = new JsonFileTokenRepository(new FileSystem());
            IAuthenticator   authenticator = new VstsOAuthAuthenticator(httpClient, repository, vstsConfig);

            File.Copy($"..//..//..//testdata//{TokenFilename}", fullTokenFilename, true);

            AuthenticationResult authResult = authenticator.Authenticate();

            File.Copy(fullTokenFilename, $"..//..//..//testdata//{TokenFilename}", true);

            this.sut = new VstsSyncReleaseClient(vstsConfig);

            ReleaseEnvironment result = this.sut.UpdateReleaseEnvironment(11, 11, authResult.AccessToken);

            Assert.NotNull(result);
            Assert.Equal(EnvironmentStatus.Queued, result.Status);
        }
Exemple #3
0
        public void GetReleaseDefinition_Succeeds()
        {
            VstsConfig vstsConfig = GetVstsConfig();

            IHttpClient      httpClient    = new HttpClient();
            ITokenRepository repository    = new JsonFileTokenRepository(new FileSystem());
            IAuthenticator   authenticator = new VstsOAuthAuthenticator(httpClient, repository, vstsConfig);

            File.Copy($"..//..//..//testdata//{TokenFilename}", fullTokenFilename, true);

            AuthenticationResult authResult = authenticator.Authenticate();

            File.Copy(fullTokenFilename, $"..//..//..//testdata//{TokenFilename}", true);

            this.sut = new VstsSyncReleaseClient(vstsConfig);

            ReleaseDefinition result = this.sut.GetReleaseDefinition(1, authResult.AccessToken);

            Assert.NotNull(result);

            SaveResultData(result, "../../../testdata/GetReleaseDefinition.json");
        }
Exemple #4
0
        public void UpdateApproval_Succeeds()
        {
            VstsConfig vstsConfig = GetVstsConfig();

            IHttpClient      httpClient    = new HttpClient();
            ITokenRepository repository    = new JsonFileTokenRepository(new FileSystem());
            IAuthenticator   authenticator = new VstsOAuthAuthenticator(httpClient, repository, vstsConfig);

            File.Copy($"..//..//..//testdata//{TokenFilename}", fullTokenFilename, true);

            AuthenticationResult authResult = authenticator.Authenticate();

            File.Copy(fullTokenFilename, $"..//..//..//testdata//{TokenFilename}", true);

            this.sut = new VstsSyncReleaseClient(vstsConfig);

            ReleaseApproval result = this.sut.UpdateApproval(123, authResult.AccessToken);

            Assert.NotNull(result);
            Assert.Equal(ApprovalStatus.Approved, result.Status);

            SaveResultData(result, "../../../testdata/UpdateApproval.json");
        }