Beispiel #1
0
        public void RunBuildConfiguration_BuildResponse_WithParameters()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Id("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake <IBuildConfigurationRetriever>();

            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
            .Returns(new BuildConfiguration {
                Id = "bt2"
            });
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<properties>\r\n<property name=\"param1\" value=\"value1\"/>\r\n</properties>\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue", A <object[]> .Ignored))
            .Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever);

            // Act
            var build = connectedTc.RunBuildConfiguration(having, p => p.Parameter("param1", "value1"));

            // Assert
            build.Should().NotBe(null);
            build.Id.ShouldBeEquivalentTo(123);
            build.Status.ShouldBeEquivalentTo(BuildStatus.Success);
        }
Beispiel #2
0
        public void RunBuildConfiguration_BuildResponse()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake <IBuildConfigurationRetriever>();

            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
            .Returns(new BuildConfiguration {
                Id = "bt2"
            });
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>("<build>\r\n<buildType id=\"bt2\"/>\r\n</build>\r\n",
                                                            HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue", A <object[]> .Ignored))
            .Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever);

            // Act
            var build = connectedTc.RunBuildConfiguration(having);

            // Assert
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>("<build>\r\n<buildType id=\"bt2\"/>\r\n</build>\r\n",
                                                            HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue", A <object[]> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Once);
            build.Should().NotBe(null);
            build.Id.ShouldBeEquivalentTo(123);
            build.Status.ShouldBeEquivalentTo(BuildStatus.Success);
        }
Beispiel #3
0
        public void RunBuildConfiguration_Personal_CleanSources_QueueTop()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake <IBuildConfigurationRetriever>();

            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
            .Returns(new BuildConfiguration {
                Id = "bt2"
            });
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<triggeringOptions cleanSources=\"true\" queueAtTop=\"true\" />\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue"))
            .Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever);

            // Act
            var build = connectedTc.RunBuildConfiguration(having, options => options.WithCleanSources().QueueAtTop());

            // Assert
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<triggeringOptions cleanSources=\"true\" queueAtTop=\"true\" />\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue"))
            .MustHaveHappened(Repeated.Exactly.Once);
            build.Id.ShouldBeEquivalentTo(123);
            build.Status.ShouldBeEquivalentTo(BuildStatus.Success);
        }
Beispiel #4
0
        public void RunBuildConfiguration_WithComment_SpecialCharacters()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake <IBuildConfigurationRetriever>();

            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
            .Returns(new BuildConfiguration {
                Id = "bt2"
            });
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<comment><text>comment&lt;HAHA&gt;</text></comment>\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue"))
            .Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever);

            // Act
            var build = connectedTc.RunBuildConfiguration(having, options => options.WithComment("comment<HAHA>"));

            // Assert
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<comment><text>comment&lt;HAHA&gt;</text></comment>\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue"))
            .MustHaveHappened(Repeated.Exactly.Once);
            build.Id.ShouldBeEquivalentTo(123);
            build.Status.ShouldBeEquivalentTo(BuildStatus.Success);
        }
Beispiel #5
0
        public void RunBuildConfiguration_OnAgentNameWithParameters()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake <IBuildConfigurationRetriever>();

            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
            .Returns(new BuildConfiguration {
                Id = "bt2"
            });
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<agent id=\"9\"/>\r\n<properties>\r\n<property name=\"param1\" value=\"value1\"/>\r\n</properties>\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue"))
            .Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

            Action <IAgentHavingBuilder> onAgent = p => p.Name("agent1");
            var agentsRetriever = A.Fake <IAgentsRetriever>();

            A.CallTo(() => agentsRetriever.GetAgent(onAgent)).Returns(new Agent()
            {
                Id = 9
            });

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever, agentsRetriever);

            // Act
            var build = connectedTc.RunBuildConfiguration(having, onAgent, p => p.Parameter("param1", "value1"));

            // Assert
            A.CallTo(() =>
                     teamCityCaller.PostFormat <BuildModel>(
                         "<build>\r\n<buildType id=\"bt2\"/>\r\n<agent id=\"9\"/>\r\n<properties>\r\n<property name=\"param1\" value=\"value1\"/>\r\n</properties>\r\n</build>\r\n",
                         HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson, "/app/rest/buildQueue", A <object[]> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Once);
            build.Id.ShouldBeEquivalentTo(123);
            build.Status.ShouldBeEquivalentTo(BuildStatus.Success);
        }
Beispiel #6
0
        public void RunBuildConfiguration_OnAgentNameWithParameters()
        {
            // Arrange
            Action<IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake<IBuildConfigurationRetriever>();
            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
                .Returns(new BuildConfiguration {Id = "bt2"});

            Action<IAgentHavingBuilder> onAgent = p => p.Name("agent1");
            var agentsRetriever = A.Fake<IAgentsRetriever>();
            A.CallTo(() => agentsRetriever.GetAgent(onAgent)).Returns(new Agent() {Id = 9});

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever, agentsRetriever);

            // Act
            connectedTc.RunBuildConfiguration(having, onAgent, p => p.Parameter("param1", "value1"));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Post(@"<build>
            <buildType id=""bt2""/>
            <agent id=""9""/>
            <properties>
            <property name=""param1"" value=""value1""/>
            </properties>
            </build>
            ", HttpContentTypes.ApplicationXml, "/app/rest/buildQueue", string.Empty))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #7
0
        public void RunBuildConfiguration_ConfigurationName()
        {
            // Arrange
            Action<IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake<IBuildConfigurationRetriever>();
            A.CallTo(() => buildConfigurationRetriever.GetSingleBuildConfiguration(having))
                .Returns(new BuildConfiguration {Id = "bt2"});

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller, buildConfigurationRetriever);

            // Act
            connectedTc.RunBuildConfiguration(having);

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Post(@"<build>
            <buildType id=""bt2""/>
            </build>
            ", HttpContentTypes.ApplicationXml, "/app/rest/buildQueue", string.Empty))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }