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
        private static IDeploymentService BuildService()
        {
            VstsConfig  vstsConfig = GetVstsConfig();
            IFileSystem fileSystem = new FileSystem();
            IHttpClient httpClient = new HttpClient();
            IProductManifestRepository manifestRepository = new JsonFileProductManifestRepository(fileSystem);
            ITokenRepository           tokenRepository    = new JsonFileTokenRepository(fileSystem);
            IVstsReleaseClient         releaseClient      = new VstsSyncReleaseClient(vstsConfig);
            IAuthenticator             authenticator      = new VstsOAuthAuthenticator(httpClient, tokenRepository, vstsConfig);
            IReleaseRepository         releaseRepository  = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig);
            IServiceDeploymentExecutor deploymentExecutor = new VstsDeploymentExecutor(releaseRepository, vstsConfig);
            IServiceDeploymentHandler  deploymentHandler  = new SequentialDeploymentHandler(deploymentExecutor, 10);
            IDeploymentService         service            = new DeploymentService(manifestRepository, deploymentHandler);

            return(service);
        }
Exemple #3
0
        public void GetReleaseId__Succeeds()
        {
            VstsConfig         vstsConfig      = GetVstsConfig();
            IVstsReleaseClient releaseClient   = new VstsSyncReleaseClient(vstsConfig);
            IHttpClient        httpClient      = new HttpClient();
            ITokenRepository   tokenRepository =
                new JsonFileTokenRepository(new FileSystem());
            IAuthenticator authenticator =
                new VstsOAuthAuthenticator(httpClient, tokenRepository, vstsConfig);

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

            this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig);

            string result = this.sut.GetReleaseId("samplepackage", "1.1.11");

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

            Assert.NotNull(result);
        }
Exemple #4
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 #5
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 #6
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");
        }