public void IfAnyBuildsAreRunningStartLightPattern() { const string baseUrl = "http://server/teamcity"; const string response1 = "{" + "'count': 1," + "'nextHref': '/guestAuth/app/rest/builds?locator=count:100,start:100,branch:(default:any)'," + "'build': [{" + "'id': 2052," + "'number': '811'," + "'status': 'FAILURE'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/auth'," + "'startDate': '20140312T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2052'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2052&buildTypeId=TestApi_Continuous'" + "}]" + "}"; const string response2 = "{" + "'count': 1," + "'build': [{" + "'id': 2088," + "'number': '247'," + "'running': 'true'," + "'percentageComplete': '24'," + "'status': 'SUCCESS'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/auth'," + "'defaultBranch': 'false'," + "'startDate': '20140313T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2088'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2088&buildTypeId=TestApi_Continuous'" + "}]" + "}"; var mockSiren = MockRepository.GenerateMock<ISirenOfShameDevice>(); mockSiren.Expect(x => x.TryConnect()).Return(true); mockSiren.Expect(x => x.PlayLightPattern(Arg<LedPattern>.Is.Anything, Arg<TimeSpan>.Is.Anything)); var responses = new Stack<string>(); responses.Push(response1); responses.Push(response2); var httpClient = BuildHttpClient(responses); var sosManager = new SirenOfShameManager(mockSiren); var client = new TeamCityManager(new BuildServer(baseUrl), httpClient, sosManager); client.AddProject("TestApi_Continuous-[feature/auth]"); var result = client.GetCruiseServerSnapshot(); Assert.AreEqual(ProjectActivity.Building, result.ProjectStatuses[0].Activity); mockSiren.VerifyAllExpectations(); }
public void GetSnapshotWithNoRunningBuilds() { const string baseUrl = "http://server/teamcity"; const string response1 = "{" + "'count': 1," + "'nextHref': '/guestAuth/app/rest/builds?locator=count:100,start:100,branch:(default:any)'," + "'build': [{" + "'id': 2051," + "'number': '810'," + "'status': 'SUCCESS'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/settings'," + "'startDate': '20140311T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2051'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2051&buildTypeId=TestApi_Continuous'" + "}]," + "'build': [{" + "'id': 2052," + "'number': '811'," + "'status': 'FAILURE'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/auth'," + "'startDate': '20140312T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2052'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2052&buildTypeId=TestApi_Continuous'" + "}]" + "}"; const string response2 = "{'count': 0}"; var responses = new Stack<string>(); responses.Push(response1); responses.Push(response2); var httpClient = BuildHttpClient(responses); var client = new TeamCityManager(new BuildServer(baseUrl), httpClient); client.AddProject("TestApi_Continuous-[feature/auth]"); client.AddProject("TestApi_Continuous-[feature/settings]"); var result = client.GetCruiseServerSnapshot(); Assert.AreEqual(2, result.ProjectStatuses.Length); }
public void GetSnapshotWithRunningBuild() { const string baseUrl = "http://server/teamcity"; const string response1 = "{" + "'count': 2," + "'nextHref': '/guestAuth/app/rest/builds?locator=count:100,start:100,branch:(default:any)'," + "'build': [{" + "'id': 2051," + "'number': '810'," + "'status': 'SUCCESS'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/settings'," + "'startDate': '20140311T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2051'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2051&buildTypeId=TestApi_Continuous'" + "}]," + "'build': [{" + "'id': 2052," + "'number': '811'," + "'status': 'FAILURE'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/auth'," + "'startDate': '20140312T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2052'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2052&buildTypeId=TestApi_Continuous'" + "}]" + "}"; const string response2 = "{" + "'count': 1," + "'build': [{" + "'id': 2088," + "'number': '247'," + "'running': 'true'," + "'percentageComplete': '24'," + "'status': 'SUCCESS'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/auth'," + "'defaultBranch': 'false'," + "'startDate': '20140313T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2088'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2088&buildTypeId=TestApi_Continuous'" + "}]" + "}"; var responses = new Stack<string>(); responses.Push(response1); responses.Push(response2); var httpClient = BuildHttpClient(responses); var client = new TeamCityManager(new BuildServer(baseUrl), httpClient); client.AddProject("TestApi_Continuous-[feature/auth]"); client.AddProject("TestApi_Continuous-[feature/settings]"); var result = client.GetCruiseServerSnapshot(); Assert.AreEqual(2, result.ProjectStatuses.Length); Assert.AreEqual("TestApi_Continuous-[feature/auth]", result.ProjectStatuses[0].Name); Assert.AreEqual(IntegrationStatus.Failure, result.ProjectStatuses[0].BuildStatus); Assert.AreEqual("Failure", result.ProjectStatuses[0].Category); Assert.AreEqual("247", result.ProjectStatuses[0].LastBuildLabel); Assert.AreEqual("https://server/teamcity/viewLog.html?buildId=2088&buildTypeId=TestApi_Continuous", result.ProjectStatuses[0].WebURL); Assert.AreEqual(ProjectActivity.Building, result.ProjectStatuses[0].Activity); Assert.AreEqual("Percent Complete: 24", result.ProjectStatuses[0].CurrentMessage); Assert.AreEqual("TestApi_Continuous-[feature/settings]", result.ProjectStatuses[1].Name); Assert.AreEqual(IntegrationStatus.Success, result.ProjectStatuses[1].BuildStatus); Assert.AreEqual("Success", result.ProjectStatuses[1].Category); Assert.AreEqual("810", result.ProjectStatuses[1].LastBuildLabel); Assert.AreEqual("https://server/teamcity/viewLog.html?buildId=2051&buildTypeId=TestApi_Continuous", result.ProjectStatuses[1].WebURL); Assert.AreEqual(ProjectActivity.Sleeping, result.ProjectStatuses[1].Activity); Assert.AreEqual("", result.ProjectStatuses[1].CurrentMessage); }
public void GetSnapshotShouldPopulateBuildTime() { const string baseUrl = "http://server/teamcity"; const string response1 = "{" + "'count': 1," + "'nextHref': '/guestAuth/app/rest/builds?locator=count:100,start:100,branch:(default:any)'," + "'build': [{" + "'id': 2051," + "'number': '810'," + "'status': 'SUCCESS'," + "'buildTypeId': 'TestApi_Continuous'," + "'branchName': 'feature/settings'," + "'startDate': '20140311T170452+0000'," + "'href': '/guestAuth/app/rest/builds/id:2051'," + "'webUrl': 'https://server/teamcity/viewLog.html?buildId=2051&buildTypeId=TestApi_Continuous'" + "}]," + "}"; const string response2 = "{}"; var responses = new Stack<string>(); responses.Push(response1); responses.Push(response2); var httpClient = BuildHttpClient(responses); var client = new TeamCityManager(new BuildServer(baseUrl), httpClient); client.AddProject("TestApi_Continuous-[feature/settings]"); var result = client.GetCruiseServerSnapshot(); Assert.AreEqual("3/11/2014 12:04:52 PM", result.ProjectStatuses[0].LastBuildDate.ToString()); }