public void WhenOneCruiseServerSnapshotIsReturnedThisIsContainedInTheReturnedXml()
        {
            CruiseServerSnapshot cruiseServerSnapshot = CreateCruiseServerSnapshot();

            CruiseServerSnapshotOnServer cruiseServerSnapshotOnServer = new CruiseServerSnapshotOnServer(cruiseServerSnapshot, null);

            mockFarmService.Setup(service => service.GetCruiseServerSnapshotListAndExceptions(null)).
            Returns(new CruiseServerSnapshotListAndExceptions(new CruiseServerSnapshotOnServer[] { cruiseServerSnapshotOnServer }, new CruiseServerException[0])).
            Verifiable();

            XmlFragmentResponse response = (XmlFragmentResponse)reportAction.Execute(null);
            string xml = response.ResponseFragment;

            // cannot just compare the xml string, since we correctly expect the string to vary based on the
            // timezone in which this code is executing
            XmlDocument doc = XPathAssert.LoadAsDocument(xml);

            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@name", "HelloWorld");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@activity", "Sleeping");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@lastBuildStatus", "Success");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@lastBuildLabel", "build_7");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@lastBuildTime", LastBuildTime);
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@nextBuildTime", NextBuildTime);
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@webUrl", "http://blah");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@category", "category");
            XPathAssert.Matches(doc, "/CruiseControl/Projects/Project/@serverName", Environment.MachineName);

            XPathAssert.Matches(doc, "/CruiseControl/Queues/Queue/@name", "Queue1");
            XPathAssert.Matches(doc, "/CruiseControl/Queues/Queue/Request/@projectName", "HelloWorld");
            XPathAssert.Matches(doc, "/CruiseControl/Queues/Queue/Request/@activity", "CheckingModifications");

            mockFarmService.Verify();
        }
        public void WhenOneProjectStatusIsReturnedThisIsContainedInTheReturnedXml()
        {
            ProjectStatus  projectStatus   = CreateProjectStatus();
            ServerLocation ServerSpecifier = new ServerLocation();

            ServerSpecifier.ServerName = "localhost";

            ProjectStatusOnServer projectStatusOnServer = new ProjectStatusOnServer(projectStatus, ServerSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions",
                                            new ProjectStatusListAndExceptions(
                                                new ProjectStatusOnServer[] { projectStatusOnServer }, new CruiseServerException[0]),
                                            (string)null);

            XmlFragmentResponse response = (XmlFragmentResponse)reportAction.Execute(null);
            string      xml = response.ResponseFragment;
            XmlDocument doc = XPathAssert.LoadAsDocument(xml);

            XPathAssert.Matches(doc, "/Projects/Project/@name", "HelloWorld");
            XPathAssert.Matches(doc, "/Projects/Project/@activity", "Sleeping");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildStatus", "Success");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildLabel", "build_7");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildTime", LastBuildTime);
            XPathAssert.Matches(doc, "/Projects/Project/@nextBuildTime", NextBuildTime);
            XPathAssert.Matches(doc, "/Projects/Project/@webUrl", "http://blah");
            XPathAssert.Matches(doc, "/Projects/Project/@category", "category");

            mockFarmService.Verify();
        }
        public void WriteSingleProject()
        {
            CruiseXmlWriter writer   = new CruiseXmlWriter();
            ProjectStatus   status   = ProjectStatusFixture.New("test");
            string          xml      = writer.Write(status);
            XmlDocument     document = XPathAssert.LoadAsDocument(xml);

            XPathAssert.Matches(document, "/CruiseControl/Projects/Project/@name", "test");
        }
        public void GenerateXmlContentForSpecifiedProject()
        {
            ProjectStatusOnServer status  = new ProjectStatusOnServer(ProjectStatusFixture.New("wrong"), serverSpecifier);
            ProjectStatusOnServer status2 = new ProjectStatusOnServer(ProjectStatusFixture.New("test"), serverSpecifier);

            mockFarmService.Setup(service => service.GetProjectStatusListAndCaptureExceptions(null)).Returns(ProjectStatusList(status, status2)).Verifiable();

            IResponse response = report.Execute((ICruiseRequest)mockRequest.Object);

            Assert.That(response, Is.InstanceOf <XmlFragmentResponse>());
            string xml = ((XmlFragmentResponse)response).ResponseFragment;

            XPathAssert.Matches(XPathAssert.LoadAsDocument(xml), "/CruiseControl/Projects/Project/@name", "test");
        }
예제 #5
0
        public void GenerateXmlContentForSpecifiedProject()
        {
            ProjectStatusOnServer status  = new ProjectStatusOnServer(ProjectStatusFixture.New("wrong"), serverSpecifier);
            ProjectStatusOnServer status2 = new ProjectStatusOnServer(ProjectStatusFixture.New("test"), serverSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", ProjectStatusList(status, status2), null);

            IResponse response = report.Execute((ICruiseRequest)mockRequest.MockInstance);

            Assert.IsInstanceOfType(typeof(XmlFragmentResponse), response);
            string xml = ((XmlFragmentResponse)response).ResponseFragment;

            XPathAssert.Matches(XPathAssert.LoadAsDocument(xml), "/CruiseControl/Projects/Project/@name", "test");
        }