public void GetBuildStateShouldIgnoreCase() { SetupMockConnectionHelper(MockUrl, SetUpExpectedResultXml(String.Format("<lastBuild><number>{0}</number><url>{1}</url></lastBuild>", ExpectedResult.BuildNumber, ExpectedResult.Link))); SetupMockConnectionHelper(ExpectedResult.ApiLink, XDocument.Parse("<build><result>FAILURE</result></build>")); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.AreNotEqual(Build.BuildState.Unknown, buildToTest.State); Assert.AreEqual(Build.BuildState.Failure, buildToTest.State); }
public void GetCurrentBuildFindsLatestBuildState() { var lastCompletedBuild = new Build {BuildNumber = "1", Link = "lastCompletedBuildUrl"}; SetupMockConnectionHelper(MockUrl, XDocument.Parse( String.Format("<root><lastBuild><number>{0}</number><url>{1}</url></lastBuild><build><number>{2}</number><url>{3}</url></build></root>", ExpectedResult.BuildNumber, ExpectedResult.Link, lastCompletedBuild.BuildNumber, lastCompletedBuild.Link))); SetupMockConnectionHelper(ExpectedResult.ApiLink, XDocument.Parse("<build><building>true</building></build>")); SetupMockConnectionHelper(lastCompletedBuild.ApiLink, XDocument.Parse("<build><result>Failure</result></build>")); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.AreEqual(Build.BuildState.Failure, buildToTest.State); }
public void GetCurrentBuildReturnsBuildState() { SetupMockConnectionHelper(MockUrl, SetUpExpectedResultXml()); SetupMockConnectionHelper(ExpectedResult.ApiLink, XDocument.Parse("<build><result>Success</result></build>")); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.AreEqual(ExpectedResult.State, buildToTest.State); Assert.IsFalse(buildToTest.IsBuilding); }
public void GetCurrentBuildReturnsBuildDetails() { SetupMockConnectionHelper(MockUrl, SetUpExpectedResultXml()); SetupMockConnectionHelper(ExpectedResult.ApiLink, new XDocument()); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.AreEqual(ExpectedResult.BuildNumber, buildToTest.BuildNumber); Assert.AreEqual(ExpectedResult.Link, buildToTest.Link); }
public void GetCurrentBuildWithUnrecognizedBuildState() { SetupMockConnectionHelper(MockUrl, SetUpExpectedResultXml()); SetupMockConnectionHelper(ExpectedResult.ApiLink, XDocument.Parse("<build><result>Succeed</result></build>")); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.AreEqual(Build.BuildState.Unknown, buildToTest.State); }
public void GetCurrentBuildThrowsExceptionWithInvalidResponse() { SetupMockConnectionHelper(MockUrl, new XDocument()); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); _buildRepositoryToTest.GetCurrentBuild(MockUrl); }
public void GetCurrentBuildReturnsIsCurrentlyBuilding() { SetupMockConnectionHelper(MockUrl, SetUpExpectedResultXml()); SetupMockConnectionHelper(ExpectedResult.ApiLink, XDocument.Parse("<build><building>true</building><result>Unstable</result></build>")); _buildRepositoryToTest = new BuildRepository(_mockHelper.Object); var buildToTest = _buildRepositoryToTest.GetCurrentBuild(MockUrl); Assert.IsTrue(buildToTest.IsBuilding); }