Пример #1
0
        public void GetSingleSuccessfulFinishedBuild()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            A.CallTo(
                () =>
                teamCityCaller.Get <BuildWrapper>(
                    @"/app/rest/builds?locator=buildType:id:FluentTc,running:False,status:SUCCESS,count:1,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl,finishDate,startDate)"))
            .Returns(new BuildWrapper {
                Build = new List <BuildModel>(new [] { new BuildModel {
                                                           Id = 123, Status = "SUCCESS"
                                                       } }), Count = "1"
            });

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

            // Act
            var builds = connectedTc.GetBuilds(which => which
                                               .BuildConfiguration(b => b.Id("FluentTc"))
                                               .NotRunning()
                                               .Status(BuildStatus.Success),
                                               with => with.IncludeFinishDate()
                                               .IncludeStartDate(),
                                               count => count.Count(1));

            // Assert
            builds.Single().Id.Should().Be(123);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public void GetLastBuild_BuildConfigurationStatus_BuildWithWithAllDetails()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            A.CallTo(
                () =>
                teamCityCaller.Get <BuildWrapper>(
                    "/app/rest/builds?locator=buildType:id:bt2,status:SUCCESS,count:1,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl)"))
            .Returns(new BuildWrapper {
                Count = "1", Build = new List <BuildModel>(new[] { new BuildModel {
                                                                       Id = 987, Status = "FAILURE"
                                                                   } })
            });
            A.CallTo(() => teamCityCaller.Get <BuildModel>("/app/rest/builds/id:987"))
            .Returns(new BuildModel {
                Id = 987, Status = "SUCCESS"
            });

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

            // Act
            var build =
                connectedTc.GetLastBuild(_ => _.BuildConfiguration(__ => __.Id("bt2")).Status(BuildStatus.Success));

            // Assert
            build.Id.Should().Be(987);
            build.Status.Should().Be(BuildStatus.Success);
        }
Пример #5
0
        public void GetBuildConfiguration_Id()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            A.CallTo(() => teamCityCaller.Get <BuildTypeWrapper>("/app/rest/buildTypes?locator=id:bt123"))
            .Returns(new BuildTypeWrapper {
                BuildType = new List <BuildConfiguration>(new[] { new BuildConfiguration {
                                                                      Id = "bt123"
                                                                  } })
            });
            A.CallTo(() => teamCityCaller.Get <BuildConfiguration>("/app/rest/buildTypes/id:bt123"))
            .Returns(new BuildConfiguration {
                Id = "bt123", SnapshotDependencies = new SnapshotDependencies {
                    SnapshotDependency = new List <SnapshotDependency>(new[] { new SnapshotDependency()
                                                                               {
                                                                                   Id = "dep.bt123"
                                                                               } })
                }
            });

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

            // Act
            var buildConfiguration = connectedTc.GetBuildConfiguration(_ => _.Id("bt123"));

            // Assert
            buildConfiguration.SnapshotDependencies.SnapshotDependency.Single().Id.Should().Be("dep.bt123");
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
0
 private static void GetLastSuccessfulBuildsForEachConfigurationWithChanges(string projectName)
 {
     var builds =
         new RemoteTc()
         .Connect(_ => _.ToHost(TeamCityHost).AsUser(Username, Password))
         .GetLastBuild(_ => _.BuildConfiguration(__ => __.Id("Trunk_Green_Ci_Compile")).Status(BuildStatus.Success),
                       __ => __.IncludeChanges(c => c.IncludeComment().IncludeFiles().IncludeVcsRootInstance()));
 }
Пример #9
0
        private static void PrintUserDetails()
        {
            var user = new RemoteTc()
                       .Connect(_ => _.ToHost(TeamCityHost).AsUser(Username, Password))
                       .GetUser(_ => _.Username(Username));

            Console.WriteLine("Name: {0}", user.Name);
            Console.WriteLine("Email: {0}", user.Email);
            Console.WriteLine("Last Login: {0}", user.LastLogin);
        }
Пример #10
0
        public void Connect_Guest_NotNull()
        {
            // Arrange
            var remoteTc = new RemoteTc();

            // Act
            var connectedTc = remoteTc.Connect(_ => _.AsGuest());

            // Assert
            connectedTc.Should().NotBeNull();
        }
Пример #11
0
        private static void PrintAllUserEmails()
        {
            var connectedTc = new RemoteTc()
                              .Connect(_ => _.ToHost(TeamCityHost).AsUser(Username, Password));

            connectedTc
            .GetAllUsers()
            .Select(u => connectedTc.GetUser(_ => _.Id(u.Id)))
            .ToList()
            .ForEach(u => Console.WriteLine(u.Email));
        }
Пример #12
0
        public void Connect_Guest_NotNull()
        {
            // Arrange
            var remoteTc = new RemoteTc();

            // Act
            var connectedTc = remoteTc.Connect(_ => _.AsGuest());

            // Assert
            connectedTc.Should().NotBeNull();
        }
Пример #13
0
        public void Sample_Usage()
        {
            // Builds

            var builds = new RemoteTc().Connect(a => a.ToHost("tc").AsGuest())
                .GetBuilds(h => h.BuildConfiguration(r => r.Id("bt2")));

            builds = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuilds(_ => _.Personal(), _ => _.Count(5), _ => _.IncludeDefaults());

            builds = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuilds(_ => _.Personal(), _ => _.Count(5), _ => _.IncludeDefaults());

            builds = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuilds(_ => _.BuildConfiguration(x => x.Id("bt2")).NotPersonal().NotRunning(), _ => _.Count(5), _ => _.IncludeDefaults());

            var build = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuild(_ => _.Id(123456), _ => _.IncludeDefaults());

            build = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuild(_ => _.Id(123456));

            // Build configurations
            BuildConfiguration build2 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .GetBuildConfiguration(_ => _.Id("bt2"), _ => _.IncludeDefaults());

            BuildConfiguration build3 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .SetParameters(_ => _.Id("bt2"),
                    _ => _.Parameters("name", "value").Parameters("name2", "value"));

            BuildConfiguration build4 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .RunBuildConfiguration(_ => _.Id("bt2"));

            BuildConfiguration build5 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .RunBuildConfiguration(_ => _.Id("bt2"),
                    _ => _.Parameters("name", "value").Parameters("name2", "value"));

            BuildConfiguration build6 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .RunBuildConfiguration(_ => _.Id("bt2"), _ => _.AgentName("agent1"));

            BuildConfiguration build7 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .RunBuildConfiguration(_ => _.Id("bt2"), _ => _.AgentName("agent1"),
                    _ => _.Parameters("name", "value").Parameters("name2", "value"));

            BuildConfiguration build8 = new RemoteTc().Connect(_ => _.ToHost("tc"))
                .CreateBuildConfiguration(_ => _.ProjectId("Trunk"), "config name");

            new RemoteTc().Connect(_ => _.ToHost("tc"))
                .AttachBuildConfigurationToTemplate(_ => _.Name("Trunk"), _ => _.TemplateName("config name"));

            new RemoteTc().Connect(_ => _.ToHost("tc"))
                .DeleteBuildConfiguration(_ => _.Name("Trunk"));
        }
Пример #14
0
        public void GetUser_ByUsername()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            User user = connectedTc.GetUser(_ => _.Username("boris.m"));

            // Assert
            A.CallTo(() => teamCityCaller.Get <User>(@"/app/rest/users/username:boris.m")).MustHaveHappened();
        }
Пример #15
0
        public void RemoveBuildFromQueue_BuildId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.RemoveBuildFromQueue(_ => _.Id(123));

            // Assert
            A.CallTo(() => teamCityCaller.Delete("/app/rest/buildQueue/id:123")).MustHaveHappened();
        }
Пример #16
0
        public void GetAllBuildConfigurationTemplates()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.GetAllBuildConfigurationTemplates();

            // Assert
            A.CallTo(() => teamCityCaller.Get <BuildTypeWrapper>(@"/app/rest/buildTypes?locator=templateFlag:true")).MustHaveHappened();
        }
Пример #17
0
        public void GetAllProjects()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.GetAllProjects();

            // Assert
            A.CallTo(() => teamCityCaller.Get <ProjectWrapper>(@"/app/rest/projects/")).MustHaveHappened();
        }
Пример #18
0
        public void CreateBuildConfiguration_ByName()
        {
            // Arrange
            Action <IBuildProjectHavingBuilder> having = _ => _.Name("OpenSource");
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            BuildConfiguration buildConfiguration = connectedTc.CreateBuildConfiguration(having, "NewConfig");

            // Assert
            A.CallTo(() => teamCityCaller.Post("NewConfig", HttpContentTypes.TextPlain, "/app/rest/projects/name:OpenSource/buildTypes", HttpContentTypes.ApplicationJson)).MustHaveHappened();
        }
Пример #19
0
        public void CreateBuildConfiguration_ByName()
        {
            // Arrange
            Action<IBuildProjectHavingBuilder> having = _ => _.Name("OpenSource");
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            BuildConfiguration buildConfiguration = connectedTc.CreateBuildConfiguration(having, "NewConfig");

            // Assert
            A.CallTo(() => teamCityCaller.Post("NewConfig", HttpContentTypes.TextPlain, "/app/rest/projects/name:OpenSource/buildTypes", HttpContentTypes.ApplicationJson)).MustHaveHappened();
        }
Пример #20
0
        public void RemoveBuildFromQueue_ProjectName()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.RemoveBuildFromQueue(_ => _.Project(__ => __.Id("FluentTc")));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.Delete("/app/rest/buildQueue/?locator=project:id:FluentTc")).MustHaveHappened();
        }
Пример #21
0
        public void CreateProject_Name()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            Project project = connectedTc.CreateProject(with => with.Name("New Project Name"));

            var data = @"<newProjectDescription name='New Project Name'></newProjectDescription>";

            // Assert
            A.CallTo(() => teamCityCaller.Post(data, HttpContentTypes.ApplicationXml, "/app/rest/projects/", HttpContentTypes.ApplicationJson)).MustHaveHappened();
        }
Пример #22
0
        public void CreateProject_Name()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            Project project = connectedTc.CreateProject(with => with.Name("New Project Name"));

            var data = @"<newProjectDescription name='New Project Name'></newProjectDescription>";

            // Assert
            A.CallTo(() => teamCityCaller.Post(data, HttpContentTypes.ApplicationXml, "/app/rest/projects/", HttpContentTypes.ApplicationJson)).MustHaveHappened();
        }
Пример #23
0
        public void GetAssignedResponsibilityFromTestNameId()
        {
            ///app/rest/investigations?locator=test:(id:-1884830467297296372)

            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            Investigation investigation = connectedTc.GetTestinvestigationByTestNameId("reallyLongNumberHere");

            // Assert
            A.CallTo(() => teamCityCaller.Get <InvestigationWrapper>(@"/app/rest/investigations?locator=test:(id:reallyLongNumberHere)")).MustHaveHappened();
        }
Пример #24
0
        public void DeleteProjectParameter_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.DeleteProjectParameter(_ => _.Id("ProjectId"), __ => __.ParameterName("param1"));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.Delete("/app/rest/projects/id:ProjectId/parameters/param1"))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #25
0
        public void AttachBuildConfigurationToTemplate()
        {
            // Arrange
            Action<IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.AttachBuildConfigurationToTemplate(having, "BuildTemplateId");

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Put("BuildTemplateId", HttpContentTypes.TextPlain, "/app/rest/buildTypes/name:FluentTc/template", string.Empty)).MustHaveHappened();
        }
Пример #26
0
        public void EnableAgent_Id()
        {
            // Arrange
            var teamCityCaller = A.Fake <TeamCityCaller>();

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

            // Act
            connectedTc.EnableAgent(_ => _.Id(123));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.PutFormat("True", "text/plain", "/app/rest/agents/{0}/enabled",
                                         A <object[]> .That.IsSameSequenceAs(new[] { "id:123" }))).MustHaveHappened();
        }
Пример #27
0
        public void AttachBuildConfigurationToTemplate()
        {
            // Arrange
            Action <IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.AttachBuildConfigurationToTemplate(having, "BuildTemplateId");

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.Put("BuildTemplateId", HttpContentTypes.TextPlain, "/app/rest/buildTypes/name:FluentTc/template", string.Empty)).MustHaveHappened();
        }
Пример #28
0
        public void DeleteBuildConfigurationParameter_ConfigurationName()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.DeleteBuildConfigurationParameter(_ => _.Name("FluentTc"), p => p.ParameterName("paramName"));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.Delete("/app/rest/buildTypes/name:FluentTc/parameters/paramName"))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #29
0
        public void SetProjectParameters_GivenParameterWithRawType_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.SetProjectParameters(_ => _.Id("ProjectId"), __ => __.Parameter("param1", "value1", t => t.AsSelectList(s => s.Value("item1"))));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.Put("{\"name\":\"param1\",\"value\":\"value1\",\"type\":{\"rawValue\":\"select data_1='item1' display='normal'\"}}",
                                   HttpContentTypes.ApplicationJson, "/app/rest/projects/id:ProjectId/parameters/param1", string.Empty))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #30
0
        public void GetBuildFullResponse_Id_Build()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            A.CallTo(() => teamCityCaller.Get <BuildModel>("/app/rest/builds/id:123")).Returns(new BuildModel {
                Id = 123, Status = "SUCCESS"
            });

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

            // Act
            var build = connectedTc.GetBuild(123);

            // Assert
            build.Id.Should().Be(123);
        }
Пример #31
0
        public void SetBuildConfigurationParameters_GivenParameterWithoutRawType_ConfigurationName()
        {
            // Arrange
            var teamCityCaller = A.Fake <TeamCityCaller>();

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

            // Act
            connectedTc.SetBuildConfigurationParameters(_ => _.Name("FluentTc"), p => p.Parameter("name", "newVal"));

            // Assert
            A.CallTo(
                () =>
                teamCityCaller.PutFormat("{\"name\":\"name\",\"value\":\"newVal\",\"type\":null}",
                                         HttpContentTypes.ApplicationJson, "/app/rest/buildTypes/{0}/parameters/{1}", A <object[]> .That.IsSameSequenceAs(new[] { "name:FluentTc", "name" })))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #32
0
        public void DownloadArtifacts_SpecificFileByBuildId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            A.CallTo(() => teamCityCaller.Get <BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk"))
            .Returns(new BuildWrapper {
                Count = "0"
            });

            // Act
            connectedTc.DownloadArtifact(123, @"C:\DownloadArtifacts_ByBuildId", "Logs.zip");

            // Assert
            A.CallTo(() => teamCityCaller.GetDownloadFormat(A <Action <string> > .Ignored, "/app/rest/builds/id:{0}/artifacts/content/{1}", 123, "Logs.zip")).MustHaveHappened();
        }
Пример #33
0
        public void GetBuildsQueue_All()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            A.CallTo(() => teamCityCaller.Get <BuildWrapper>(@"/app/rest/buildQueue"))
            .Returns(new BuildWrapper {
                Count = "0"
            });

            // Act
            connectedTc.GetBuildsQueue();

            // Assert
            A.CallTo(() => teamCityCaller.Get <BuildWrapper>(@"/app/rest/buildQueue")).MustHaveHappened();
        }
Пример #34
0
        public void GetBuildsQueue_ByProjectId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            A.CallTo(() => teamCityCaller.Get <BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk"))
            .Returns(new BuildWrapper {
                Count = "0"
            });

            // Act
            connectedTc.GetBuildsQueue(_ => _.Project(p => p.Id("Trunk")));

            // Assert
            A.CallTo(() => teamCityCaller.Get <BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk")).MustHaveHappened();
        }
Пример #35
0
        public void GetBuildConfigurationTemplate_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            A.CallTo(
                () =>
                teamCityCaller.Get <BuildConfiguration>("/app/rest/buildTypes/id:TemplateId"))
            .Returns(new BuildConfiguration {
                Id = "TemplateId"
            });

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

            // Act
            connectedTc.GetBuildConfigurationTemplate(_ => _.Id("TemplateId"));

            // Assert
            A.CallTo(() => teamCityCaller.Get <BuildConfiguration>(@"/app/rest/buildTypes/id:TemplateId")).MustHaveHappened();
        }
Пример #36
0
        public void GetBuilds_SinceDate()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            var build = new Build {Id = 987};

            A.CallTo(
                () =>
                    teamCityCaller.Get<BuildWrapper>(
                        "/app/rest/builds?locator=sinceDate:20151026T142200%2b0000,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl)"))
                .Returns(new BuildWrapper {Count = "1", Build = new List<Build>(new[] {build})});

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

            // Act
            var builds = connectedTc.GetBuilds(_ => _.SinceDate(new DateTime(2015,10,26,16,22,0)));

            // Assert
            builds.ShouldAllBeEquivalentTo(new [] { build });
        }
Пример #37
0
        public void DeleteBuildConfigurationParameter_ConfigurationName()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.DeleteBuildConfigurationParameter(_ => _.Name("FluentTc"), p => p.ParameterName("paramName"));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Delete("/app/rest/buildTypes/name:FluentTc/parameters/paramName"))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #38
0
        public void EnableAgent_Id()
        {
            // Arrange
            var teamCityCaller = A.Fake<TeamCityCaller>();

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

            // Act
            connectedTc.EnableAgent(_ => _.Id(123));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.PutFormat("True", "text/plain", "/app/rest/agents/{0}/enabled",
                        A<object[]>.That.IsSameSequenceAs(new[] {"id:123"}))).MustHaveHappened();
        }
Пример #39
0
        public void SetBuildConfigurationParameters_ConfigurationName()
        {
            // Arrange
            var teamCityCaller = A.Fake<TeamCityCaller>();

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

            // Act
            connectedTc.SetBuildConfigurationParameters(_ => _.Name("FluentTc"), p=>p.Parameter("name","newVal"));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.PutFormat("newVal", HttpContentTypes.TextPlain, "/app/rest/buildTypes/{0}/parameters/{1}", A<object[]>.That.IsSameSequenceAs(new[] {"name:FluentTc", "name"})))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #40
0
        public void GetUser_ByUsername()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            User user = connectedTc.GetUser(_ => _.Username("boris.m"));

            // Assert
            A.CallTo(() => teamCityCaller.Get<User>(@"/app/rest/users/username:boris.m")).MustHaveHappened();
        }
Пример #41
0
        public void RemoveBuildFromQueue_ProjectName()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.RemoveBuildFromQueue(_ => _.Project(__ => __.Id("FluentTc")));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Delete("/app/rest/buildQueue/?locator=project:id:FluentTc")).MustHaveHappened();
        }
Пример #42
0
        public void GetBuildConfigurations_ByName()
        {
            // Arrange
            Action<IBuildConfigurationHavingBuilder> having = _ => _.Name("FluentTc");
            var teamCityCaller = CreateTeamCityCaller();
            A.CallTo(
                () =>
                    teamCityCaller.Get<BuildTypeWrapper>("/app/rest/buildTypes?locator=name:FluentTc"))
                .Returns(new BuildTypeWrapper { BuildType = new List<BuildConfiguration>(new[] { new BuildConfiguration { Id = "bt987" } }) });

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

            // Act
            var buildConfigurations = connectedTc.GetBuildConfigurations(having);

            // Assert
            buildConfigurations.Single().Id.Should().Be("bt987");
        }
Пример #43
0
        public void GetBuildConfigurationTemplate_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            A.CallTo(
                () =>
                    teamCityCaller.Get<BuildConfiguration>("/app/rest/buildTypes/id:TemplateId"))
                .Returns(new BuildConfiguration { Id = "TemplateId" });

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

            // Act
            connectedTc.GetBuildConfigurationTemplate(_ => _.Id("TemplateId"));

            // Assert
            A.CallTo(() => teamCityCaller.Get<BuildConfiguration>(@"/app/rest/buildTypes/id:TemplateId")).MustHaveHappened();
        }
Пример #44
0
        public void GetAssignedResponsibilityFromBuildConfiguration()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            var buildConfigurationRetriever = A.Fake<IBuildConfigurationRetriever>();
            A.CallTo(
                () =>
                    buildConfigurationRetriever.GetSingleBuildConfiguration(
                        A<Action<IBuildConfigurationHavingBuilder>>.Ignored))
                .Returns(new BuildConfiguration {Id = "bt2"});

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

            // Act
            Investigation investigation = connectedTc.GetInvestigation(_ => _.Id("bt2"));

            // Assert
            A.CallTo(() => teamCityCaller.Get<InvestigationWrapper>(@"/app/rest/investigations?locator=buildType:(id:bt2)")).MustHaveHappened();
        }
Пример #45
0
        public void GetAssignedResponsibilityFromTestNameId()
        {
            ///app/rest/investigations?locator=test:(id:-1884830467297296372)

            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            Investigation investigation = connectedTc.GetTestinvestigationByTestNameId("reallyLongNumberHere");

            // Assert
            A.CallTo(() => teamCityCaller.Get<InvestigationWrapper>(@"/app/rest/investigations?locator=test:(id:reallyLongNumberHere)")).MustHaveHappened();
        }
Пример #46
0
        public void GetAllUsers()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            List<User> users = connectedTc.GetAllUsers();

            // Assert
            A.CallTo(() => teamCityCaller.Get<UserWrapper>(@"/app/rest/users/")).MustHaveHappened();
        }
Пример #47
0
        public void DeleteProjectParameter_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.DeleteProjectParameter(_ => _.Id("ProjectId"), __ => __.ParameterName("param1"));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Delete("/app/rest/projects/id:ProjectId/parameters/param1"))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #48
0
        public void GetAllBuildConfigurationTemplates()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.GetAllBuildConfigurationTemplates();

            // Assert
            A.CallTo(() => teamCityCaller.Get<BuildTypeWrapper>(@"/app/rest/buildTypes?locator=templateFlag:true")).MustHaveHappened();
        }
Пример #49
0
        public void GetBuild_Id_Build()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            A.CallTo(
                () =>
                    teamCityCaller.Get<BuildWrapper>(
                        "/app/rest/builds?locator=id:123,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl)"))
                .Returns(new BuildWrapper {Count = "1", Build = new List<Build>(new[] {new Build {Id = 987}})});

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

            // Act
            var build = connectedTc.GetBuild(_ => _.Id(123));

            // Assert
            build.Id.Should().Be(987);
        }
Пример #50
0
        public void GetBuildConfiguration_Id()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            A.CallTo(() => teamCityCaller.Get<BuildTypeWrapper>("/app/rest/buildTypes?locator=id:bt123"))
                .Returns(new BuildTypeWrapper { BuildType = new List<BuildConfiguration>(new[] { new BuildConfiguration { Id = "bt123" } }) });
            A.CallTo(() => teamCityCaller.Get<BuildConfiguration>("/app/rest/buildTypes/id:bt123"))
                .Returns(new BuildConfiguration { Id = "bt123", SnapshotDependencies = new SnapshotDependencies { SnapshotDependency = new List<SnapshotDependency>(new[] { new SnapshotDependency() { Id = "dep.bt123" } }) } });

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

            // Act
            var buildConfiguration = connectedTc.GetBuildConfiguration(_ => _.Id("bt123"));

            // Assert
            buildConfiguration.SnapshotDependencies.SnapshotDependency.Single().Id.Should().Be("dep.bt123");
        }
Пример #51
0
        public void GetProjectById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.GetProjectById("FluentTc");

            // Assert
            A.CallTo(() => teamCityCaller.Get<Project>(@"/app/rest/projects/id:FluentTc")).MustHaveHappened();
        }
Пример #52
0
        public void GetBuildFullResponse_Id_Build()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            A.CallTo(() => teamCityCaller.Get<Build>("/app/rest/builds/id:123")).Returns(new Build { Id = 123 });

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

            // Act
            var build = connectedTc.GetBuild(123);

            // Assert
            build.Id.Should().Be(123);
        }
Пример #53
0
        public void RemoveBuildFromQueue_BuildId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.RemoveBuildFromQueue(_ => _.Id(123));

            // Assert
            A.CallTo(() => teamCityCaller.Delete("/app/rest/buildQueue/id:123")).MustHaveHappened();
        }
Пример #54
0
        public void GetBuildsQueue_All()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller);
            A.CallTo(() => teamCityCaller.Get<BuildWrapper>(@"/app/rest/buildQueue"))
                .Returns(new BuildWrapper {Count = "0"});

            // Act
            connectedTc.GetBuildsQueue();

            // Assert
            A.CallTo(() => teamCityCaller.Get<BuildWrapper>(@"/app/rest/buildQueue")).MustHaveHappened();
        }
Пример #55
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);
        }
Пример #56
0
        public void GetBuildsQueue_ByProjectId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller);
            A.CallTo(() => teamCityCaller.Get<BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk"))
                .Returns(new BuildWrapper {Count = "0"});

            // Act
            connectedTc.GetBuildsQueue(_ => _.Project(p => p.Id("Trunk")));

            // Assert
            A.CallTo(() => teamCityCaller.Get<BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk")).MustHaveHappened();
        }
Пример #57
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);
        }
Пример #58
0
        public void GetBuilds_BuildConfigurationName()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();
            var build = new Build {Id = 987};

            A.CallTo(() => teamCityCaller.Get<BuildWrapper>("/app/rest/builds?locator=buildType:name:FluentTc,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl)"))
                .Returns(new BuildWrapper {Count = "1", Build = new List<Build>(new[] {build})});

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

            // Act
            var builds = connectedTc.GetBuilds(_ => _.BuildConfiguration(__ => __.Name("FluentTc")));

            // Assert
            builds.ShouldAllBeEquivalentTo(new [] { build });
        }
Пример #59
0
        public void SetProjectParameters_ById()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

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

            // Act
            connectedTc.SetProjectParameters(_ => _.Id("ProjectId"), __ => __.Parameter("param1", "value1"));

            // Assert
            A.CallTo(
                () =>
                    teamCityCaller.Put("value1", HttpContentTypes.TextPlain, "/app/rest/projects/id:ProjectId/parameters/param1", string.Empty))
                        .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #60
0
        public void DownloadArtifacts_SpecificFileByBuildId()
        {
            // Arrange
            var teamCityCaller = CreateTeamCityCaller();

            var connectedTc = new RemoteTc().Connect(_ => _.AsGuest(), teamCityCaller);
            A.CallTo(() => teamCityCaller.Get<BuildWrapper>(@"/app/rest/buildQueue?locator=project:id:Trunk"))
                .Returns(new BuildWrapper {Count = "0"});

            // Act
            connectedTc.DownloadArtifact(123, @"C:\DownloadArtifacts_ByBuildId", "Logs.zip");

            // Assert
            A.CallTo(() => teamCityCaller.GetDownloadFormat(A<Action<string>>.Ignored, "/app/rest/builds/id:{0}/artifacts/content/{1}", 123, "Logs.zip")).MustHaveHappened();
        }