public async Task LastBuildResult_WhenBuildIsRunning_ReturnsRunningBuildStatus() { string buildId = _fixture.Create <string>(); Build build = _fixture .Build <Build>() .Create(); A.CallTo(() => _teamcityClient.Builds.LastBuildByBuildConfigId(buildId)) .Returns(build); A.CallTo(() => _teamcityClient.Builds.ByBuildId(build.Id)) .Returns(build); A.CallTo(() => _teamcityClient.Builds.ByBuildLocator(A <BuildLocator> .Ignored)) .Returns(_fixture.Build <Build>().CreateMany().ToList()); TeamCityService teamCityService = new TeamCityService(_teamcityClient); CiBuildResult result = await teamCityService.LastBuildResult(buildId); CiBuildResult expectedResult = new CiBuildResult { CiSource = CiSource.TeamCity, Id = build.Id, BuildId = build.BuildType.Id, BuildName = build.BuildType.Name, Url = build.WebUrl, FinishDate = build.FinishDate, StartDate = build.StartDate, Version = build.Number, Status = CiBuildResultStatus.Running }; result.ShouldBeEquivalentTo(expectedResult); }
public async Task LastBuildResult_ReturnsInfoCorrectlyMapped(string status, CiBuildResultStatus resultStatus) { string buildId = _fixture.Create <string>(); Build build = _fixture .Build <Build>() .With(b => b.Status, status) .Create(); A.CallTo(() => _teamcityClient.Builds.LastBuildByBuildConfigId(buildId)) .Returns(build); A.CallTo(() => _teamcityClient.Builds.ByBuildId(build.Id)) .Returns(build); TeamCityService teamCityService = new TeamCityService(_teamcityClient); CiBuildResult result = await teamCityService.LastBuildResult(buildId); CiBuildResult expectedResult = new CiBuildResult { CiSource = CiSource.TeamCity, Id = build.Id, BuildId = build.BuildType.Id, BuildName = build.BuildType.Name, Url = build.WebUrl, FinishDate = build.FinishDate, StartDate = build.StartDate, Version = build.Number, Status = resultStatus }; result.ShouldBeEquivalentTo(expectedResult); }
public async Task LastBuildResult_ReturnsStatisticsCorrectlyMapped() { string buildId = _fixture.Create <string>(); Build build = _fixture .Build <Build>() .With(b => b.Status, "SUCCESS") .Create(); A.CallTo(() => _teamcityClient.Builds.LastBuildByBuildConfigId(buildId)) .Returns(build); A.CallTo(() => _teamcityClient.Builds.ByBuildId(build.Id)) .Returns(build); List <Property> stats = new List <Property> { new Property { Name = "PassedTestCount", Value = "1" }, new Property { Name = "FailedTestCount", Value = "2" }, new Property { Name = "IgnoredTestCount", Value = "3" }, new Property { Name = "CodeCoverageAbsSCovered", Value = "4" }, new Property { Name = "CodeCoverageAbsSTotal", Value = "5" } }; A.CallTo(() => _teamcityClient.Statistics.GetByBuildId(build.Id)) .Returns(stats); TeamCityService teamCityService = new TeamCityService(_teamcityClient); CiBuildResult result = await teamCityService.LastBuildResult(buildId); CiBuildResult expectedResult = new CiBuildResult { CiSource = CiSource.TeamCity, Id = build.Id, BuildId = build.BuildType.Id, BuildName = build.BuildType.Name, Url = build.WebUrl, FinishDate = build.FinishDate, StartDate = build.StartDate, Version = build.Number, Status = CiBuildResultStatus.Success, NumberTestPassed = 1, NumberTestFailed = 2, NumberTestIgnored = 3, NumberStatementsCovered = 4, NumberStatementsTotal = 5 }; result.ShouldBeEquivalentTo(expectedResult); }
public void MapsBuildsCorrectly(string status, CiBuildResultStatus resultStatus) { Build build = _fixture .Build <Build>() .With(b => b.Status, status) .Create(); CiBuildResult mappedResult = Mapper.Map <Build, CiBuildResult>(build); CiBuildResult expectedResult = new CiBuildResult { CiSource = CiSource.TeamCity, Id = build.Id, BuildId = build.BuildType.Id, BuildName = build.BuildType.Name, Url = build.WebUrl, FinishDate = build.FinishDate, StartDate = build.StartDate, Version = build.Number, Status = resultStatus }; mappedResult.ShouldBeEquivalentTo(expectedResult); }