Пример #1
0
        private static void Main(string[] args)
        {
            #region RemoteTc

            GetBuildConfigurationParameters();
            GetLastSuccessfulBuildsForEachConfigurationWithChanges("Trunk_Ci_FastCi");

            PrintEnabledAuthorizedDisconnectedAgents();
            PrintAllUsers();
            PrintAllUserEmails();
            PrintUserDetails();
            GetBuildsTriggeredByUser();
            DeleteBuildConfigurationParameter();
            DeleteProjectParameter();

            #endregion

            #region LocalTc

            var localTc = new LocalTc();

            var buildId = localTc.GetBuildParameter <long>("build.id");
            localTc.SetBuildParameter("parameter.name", "value1");
            localTc.ChangeBuildStatus(BuildStatus.Success);

            #endregion

            Console.ReadKey();
        }
Пример #2
0
        public void SetBuildParameter_ParameterNameValue_WriteBuildParameterCalled()
        {
            // Arrange
            var buildParameters = A.Fake<IBuildParameters>();

            var localTc = new LocalTc(buildParameters, A.Fake<ITeamCityWriterFactory>());

            // Act
            localTc.SetBuildParameter("parameter.name", "value1");

            // Assert
            A.CallTo(() => buildParameters.SetBuildParameter("parameter.name", "value1")).MustHaveHappened();
        }
Пример #3
0
        public void SetBuildParameter_ParameterNameValue_WriteBuildParameterCalled()
        {
            // Arrange
            var buildParameters = A.Fake <IBuildParameters>();

            var localTc = new LocalTc(buildParameters, A.Fake <ITeamCityWriterFactory>());

            // Act
            localTc.SetBuildParameter("parameter.name", "value1");

            // Assert
            A.CallTo(() => buildParameters.SetBuildParameter("parameter.name", "value1")).MustHaveHappened();
        }
Пример #4
0
        public void IsTeamCityMode_False()
        {
            // Arrange
            var buildParameters = A.Fake <IBuildParameters>();

            A.CallTo(() => buildParameters.IsTeamCityMode).Returns(false);

            var localTc = new LocalTc(buildParameters, A.Fake <ITeamCityWriterFactory>());

            // Act
            var isTeamCityMode = localTc.IsTeamCityMode;

            // Assert
            isTeamCityMode.Should().BeFalse();
        }
Пример #5
0
        public void IsPersonal_False_False()
        {
            // Arrange
            var buildParameters = A.Fake<IBuildParameters>();
            A.CallTo(() => buildParameters.IsPersonal)
                .Returns(false);

            var localTc = new LocalTc(buildParameters, A.Fake<ITeamCityWriterFactory>());

            // Act
            bool isPersonal = localTc.IsPersonal;

            // Assert
            isPersonal.Should().BeFalse();
        }
Пример #6
0
        public void IsPersonal_False_False()
        {
            // Arrange
            var buildParameters = A.Fake <IBuildParameters>();

            A.CallTo(() => buildParameters.IsPersonal)
            .Returns(false);

            var localTc = new LocalTc(buildParameters, A.Fake <ITeamCityWriterFactory>());

            // Act
            bool isPersonal = localTc.IsPersonal;

            // Assert
            isPersonal.Should().BeFalse();
        }
Пример #7
0
        public void PublishArtifact_FileNameAndTarget_Published()
        {
            // Arrange
            var teamCityWriterFactory = A.Fake <ITeamCityWriterFactory>();
            var teamCityWriter        = A.Fake <ITeamCityWriter>();

            A.CallTo(() => teamCityWriterFactory.CreateTeamCityWriter()).Returns(teamCityWriter);

            var localTc = new LocalTc(A.Fake <IBuildParameters>(), teamCityWriterFactory);

            // Act
            localTc.PublishArtifact("file.txt", "dir");

            // Assert
            A.CallTo(() => teamCityWriter.PublishArtifact("file.txt => dir")).MustHaveHappened();
        }
Пример #8
0
        public void TryGetBuildParameter_ParameterDoesNotExist_False()
        {
            // Arrange
            var    buildParameters = A.Fake <IBuildParameters>();
            string paramValue;

            A.CallTo(() => buildParameters.TryGetBuildParameter("param1", out paramValue)).Returns(false);

            var localTc = new LocalTc(buildParameters, A.Fake <ITeamCityWriterFactory>());

            // Act
            string actualValue;
            var    paramExists = localTc.TryGetBuildParameter("param1", out actualValue);

            // Assert
            paramExists.Should().BeFalse();
        }
Пример #9
0
        public void TryGetBuildParameter_ParameterExists_True()
        {
            // Arrange
            var    buildParameters = A.Fake <IBuildParameters>();
            string paramValue;

            A.CallTo(() => buildParameters.TryGetBuildParameter("param1", out paramValue)).Returns(true)
            .AssignsOutAndRefParameters("VALUE");

            var localTc = new LocalTc(buildParameters, A.Fake <ITeamCityWriterFactory>());

            // Act
            string actualValue;
            var    paramExists = localTc.TryGetBuildParameter("param1", out actualValue);

            // Assert
            actualValue.Should().Be("VALUE");
            paramExists.Should().BeTrue();
        }
Пример #10
0
        public void ChangeBuildStatus_Success_MessageWritten()
        {
            // Arrange
            var teamCityWriter = A.Fake<ITeamCityWriter>();

            var teamCityWriterFactory = A.Fake<ITeamCityWriterFactory>();
            A.CallTo(() => teamCityWriterFactory.CreateTeamCityWriter()).Returns(teamCityWriter);

            var localTc = new LocalTc(A.Fake<IBuildParameters>(), teamCityWriterFactory);

            // Act
            localTc.ChangeBuildStatus(BuildStatus.Success);

            // Assert
            A.CallTo(() => teamCityWriter.WriteRawMessage(A<IServiceMessage>.That.Matches(
                m => m.Name == "buildStatus" &&
                m.Keys.Single() == "status" &&
                m.GetValue(m.Keys.Single()) == "SUCCESS") ))
                .MustHaveHappened();
        }
Пример #11
0
        public void ChangeBuildStatus_Failure_MessageWritten()
        {
            // Arrange
            var teamCityWriter = A.Fake <ITeamCityWriter>();

            var teamCityWriterFactory = A.Fake <ITeamCityWriterFactory>();

            A.CallTo(() => teamCityWriterFactory.CreateTeamCityWriter()).Returns(teamCityWriter);

            var localTc = new LocalTc(A.Fake <IBuildParameters>(), teamCityWriterFactory);

            // Act
            localTc.ChangeBuildStatus(BuildStatus.Failure);

            // Assert
            A.CallTo(() => teamCityWriter.WriteRawMessage(A <IServiceMessage> .That.Matches(
                                                              m => m.Name == "buildStatus" &&
                                                              m.Keys.Single() == "status" &&
                                                              m.GetValue(m.Keys.Single()) == "FAILURE")))
            .MustHaveHappened();
        }
Пример #12
0
        private static void Main(string[] args)
        {
            #region RemoteTc

            PrintEnabledAuthorizedDisconnectedAgents();
            PrintAllUsers();
            PrintAllUserEmails();
            PrintUserDetails();
            GetBuildsTriggeredByUser();
            DeleteBuildConfigurationParameter();
            DeleteProjectParameter();

            #endregion

            #region LocalTc

            var localTc = new LocalTc();

            var buildId = localTc.GetBuildParameter("build.id");
            localTc.SetBuildParameter("parameter.name", "value1");
            localTc.ChangeBuildStatus(BuildStatus.Success);

            #endregion

            Console.ReadKey();
        }
Пример #13
0
        public void TryGetBuildParameter_ParameterExists_True()
        {
            // Arrange
            var buildParameters = A.Fake<IBuildParameters>();
            string paramValue;
            A.CallTo(() => buildParameters.TryGetBuildParameter("param1", out paramValue)).Returns(true)
                .AssignsOutAndRefParameters("VALUE");

            var localTc = new LocalTc(buildParameters, A.Fake<ITeamCityWriterFactory>());

            // Act
            string actualValue;
            var paramExists = localTc.TryGetBuildParameter("param1", out actualValue);

            // Assert
            actualValue.Should().Be("VALUE");
            paramExists.Should().BeTrue();
        }
Пример #14
0
        public void TryGetBuildParameter_ParameterDoesNotExist_False()
        {
            // Arrange
            var buildParameters = A.Fake<IBuildParameters>();
            string paramValue;
            A.CallTo(() => buildParameters.TryGetBuildParameter("param1", out paramValue)).Returns(false);

            var localTc = new LocalTc(buildParameters, A.Fake<ITeamCityWriterFactory>());

            // Act
            string actualValue;
            var paramExists = localTc.TryGetBuildParameter("param1", out actualValue);

            // Assert
            paramExists.Should().BeFalse();
        }
Пример #15
0
        public void IsTeamCityMode_True()
        {
            // Arrange
            var buildParameters = A.Fake<IBuildParameters>();
            A.CallTo(() => buildParameters.IsTeamCityMode).Returns(true);

            var localTc = new LocalTc(buildParameters, A.Fake<ITeamCityWriterFactory>());

            // Act
            var isTeamCityMode = localTc.IsTeamCityMode;

            // Assert
            isTeamCityMode.Should().BeTrue();
        }