Example #1
0
        public void GetQueuedBuildNumber_WhenTwoBuildNodesUsed()
        {
            IHttpAdapter httpHelper = Mock.Create <IHttpAdapter>();

            Mock.Arrange(() => httpHelper.Get(Arg.Is <string>(@"http://*****:*****@"http://localhost:8080/job/Jenkins-CSharp-Api.Parameterized/1/api/xml"))).Returns(newSpecificBuildXml);
            Mock.Arrange(() => httpHelper.Get(Arg.Is <string>(@"http://localhost:8080/job/Jenkins-CSharp-Api.Parameterized/2/api/xml"))).Returns(newSpecificBuildXml);
            var buildAdapter    = new BuildAdapter(httpHelper, JenkinsTestData.JenkinsUrl, JenkinsTestData.ProjectName);
            int nextBuildNumber = buildAdapter.GetQueuedBuildNumber(
                JenkinsTestData.BuildStatusXml,
                "7757ae58-5ba5-4690-b49c-997779f62338");

            Assert.AreEqual <int>(
                34,
                nextBuildNumber,
                "The returned next build number was not correct.");
        }
Example #2
0
        public void GetSpecificBuildStatusXml()
        {
            IHttpAdapter httpAdapter = Mock.Create <IHttpAdapter>();

            Mock.Arrange(() => httpAdapter.Get(Arg.IsAny <string>())).Returns(JenkinsTestData.SpecificBuildXml);
            var    buildAdapter = new BuildAdapter(httpAdapter, JenkinsTestData.JenkinsUrl, JenkinsTestData.ProjectName);
            string buildStatus  = buildAdapter.GetSpecificBuildStatusXml(string.Empty);

            Assert.AreEqual <string>(
                JenkinsTestData.SpecificBuildXml,
                buildStatus,
                "The returned build status was incorrect.");
        }
        public void GetNextBuildNumber()
        {
            IHttpAdapter httpAdapter = Mock.Create <IHttpAdapter>();

            Mock.Arrange(() => httpAdapter.Get(Arg.IsAny <string>())).Returns(JenkinsTestData.BuildStatusXml);
            var    jenkinsBuild    = new BuildService(new BuildAdapter(httpAdapter, JenkinsTestData.JenkinsUrl, JenkinsTestData.ProjectName));
            string nextBuildNumber = jenkinsBuild.GetNextBuildNumber();

            Assert.AreEqual <string>(
                "35",
                nextBuildNumber,
                "The returned next build number was not correct.");
        }
Example #4
0
        public void ThrowException_WhenNoBuildIsQueued()
        {
            IHttpAdapter httpAdapter         = Mock.Create <IHttpAdapter>();
            string       newSpecificBuildXml =
                JenkinsTestData.SpecificBuildXml.Replace(
                    "<value>7757ae58-5ba5-4690-b49c-997779f62338</value>",
                    "<value>5ba5-4690-b49c-997779f62338</value>");

            Mock.Arrange(() => httpAdapter.Get(Arg.IsAny <string>())).Returns(newSpecificBuildXml);

            var buildAdapter = new BuildAdapter(httpAdapter, JenkinsTestData.JenkinsUrl, JenkinsTestData.ProjectName);

            buildAdapter.GetQueuedBuildNumber(
                JenkinsTestData.BuildStatusSingleBuildNodeXml,
                "7757ae58-5ba5-4690-b49c-997779f62338");
        }
Example #5
0
        public void GetQueuedBuildNumber_WhenSingleBuildNodeUsed()
        {
            IHttpAdapter httpAdapter = Mock.Create <IHttpAdapter>();

            Mock.Arrange(() => httpAdapter.Get(Arg.IsAny <string>())).Returns(JenkinsTestData.SpecificBuildXml);

            var buildAdapter    = new BuildAdapter(httpAdapter, JenkinsTestData.JenkinsUrl, JenkinsTestData.ProjectName);
            int nextBuildNumber = buildAdapter.GetQueuedBuildNumber(
                JenkinsTestData.BuildStatusSingleBuildNodeXml,
                "7757ae58-5ba5-4690-b49c-997779f62338");

            Assert.AreEqual <int>(
                1,
                nextBuildNumber,
                "The returned next build number was not correct.");
        }