Esempio n. 1
0
        public void GetReleaseEnvironmentStatus_DoesntGetRelease_ReturnsUnknown()
        {
            IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>();
            IAuthenticator     authenticator = Substitute.For <IAuthenticator>();
            VstsConfig         vstsConfig    = new VstsConfig();

            authenticator.Authenticate().Returns(new AuthenticationResult {
                Success = true
            });
            releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>()).Returns((Release)null);

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

            SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "999");

            Assert.Equal(SolutionDeploy.Core.DeploymentStatus.Unknown, result);
        }
Esempio n. 2
0
        public void GetReleaseEnvironmentStatus_ReleaseInProgress_ChecksForApprovals()
        {
            IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>();
            IAuthenticator     authenticator = Substitute.For <IAuthenticator>();
            VstsConfig         vstsConfig    = new VstsConfig();

            authenticator.Authenticate().Returns(new AuthenticationResult {
                Success = true
            });
            releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>()).Returns(GetTestRelease(EnvironmentStatus.InProgress));

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

            SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "123");

            releaseClient.ReceivedWithAnyArgs().GetApprovals(default(int), default(string));
        }
Esempio n. 3
0
        public void GetReleaseEnvironmentStatus_ReleaseHasNoApprovals_ReturnsInProgress()
        {
            IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>();
            IAuthenticator     authenticator = Substitute.For <IAuthenticator>();
            VstsConfig         vstsConfig    = new VstsConfig();

            authenticator.Authenticate().Returns(new AuthenticationResult {
                Success = true
            });
            releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>()).Returns(GetTestRelease(EnvironmentStatus.InProgress));
            releaseClient.GetApprovals(Arg.Any <int>(), Arg.Any <string>()).Returns(new List <ReleaseApproval>());

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

            SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "123");

            Assert.Equal(SolutionDeploy.Core.DeploymentStatus.InProgress, result);
        }
Esempio n. 4
0
        public void GetEnvironmentId_GetsEnvironment_ReturnsEnvironmentId()
        {
            IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>();
            IAuthenticator     authenticator = Substitute.For <IAuthenticator>();
            VstsConfig         vstsConfig    = new VstsConfig();

            authenticator.Authenticate().Returns(new AuthenticationResult {
                Success = true
            });
            releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>())
            .Returns(GetTestRelease(EnvironmentStatus.Succeeded));

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

            string result = this.sut.GetReleaseEnvironmentId("999", "Environment1");

            Assert.NotNull(result);
        }
Esempio n. 5
0
        internal void GetReleaseEnvironmentStatus_GetsEnvironment_ReturnsStatus(
            EnvironmentStatus envStatus,
            SolutionDeploy.Core.DeploymentStatus deployStatus)
        {
            IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>();
            IAuthenticator     authenticator = Substitute.For <IAuthenticator>();
            VstsConfig         vstsConfig    = new VstsConfig();

            authenticator.Authenticate().Returns(new AuthenticationResult {
                Success = true
            });
            releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>())
            .Returns(this.GetTestRelease(envStatus));

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

            SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "123");

            Assert.Equal(deployStatus, result);
        }