コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void GetCurrentBuildThrowsExceptionWithInvalidResponse()
 {
     SetupMockConnectionHelper(MockUrl, new XDocument());
     _buildRepositoryToTest = new BuildRepository(_mockHelper.Object);
     _buildRepositoryToTest.GetCurrentBuild(MockUrl);
 }
コード例 #7
0
        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);
        }