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"); }
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"); }
public void ExecuteGeneratesReport() { var projectName = "daProject"; var farmService = this.mocks.StrictMock <IFarmService>(); var cruiseRequest = this.mocks.StrictMock <ICruiseRequest>(); var sessionRetriever = this.mocks.StrictMock <ISessionRetriever>(); var server = this.mocks.StrictMock <IServerSpecifier>(); var project = new ProjectStatus(projectName, IntegrationStatus.Success, new DateTime(2010, 1, 2, 3, 4, 5)); project.ServerName = "TESTMACHINE"; var status = new ProjectStatusOnServer(project, server); var snapshot = new ProjectStatusListAndExceptions( new ProjectStatusOnServer[] { status }, new CruiseServerException[0]); SetupResult.For(cruiseRequest.ProjectName).Return(projectName); SetupResult.For(cruiseRequest.ServerSpecifier).Return(server); SetupResult.For(cruiseRequest.RetrieveSessionToken(sessionRetriever)).Return(null); SetupResult.For(farmService.GetProjectStatusListAndCaptureExceptions(server, null)) .Return(snapshot); this.mocks.ReplayAll(); var report = new ProjectXmlReport(farmService, sessionRetriever); var response = report.Execute(cruiseRequest); this.mocks.VerifyAll(); Assert.IsInstanceOf <XmlFragmentResponse>(response); var actual = response as XmlFragmentResponse; var expected = "<CruiseControl>" + "<Projects>" + "<Project name=\"daProject\" category=\"\" activity=\"Sleeping\" " + "status=\"Running\" lastBuildStatus=\"Success\" lastBuildLabel=\"\" " + "lastBuildTime=\"" + XmlConvert.ToString(project.LastBuildDate, XmlDateTimeSerializationMode.Local) + "\" nextBuildTime=\"" + XmlConvert.ToString(project.NextBuildTime, XmlDateTimeSerializationMode.Local) + "\" " + "webUrl=\"\" buildStage=\"\" serverName=\"TESTMACHINE\" />" + "</Projects>" + "<Queues />" + "</CruiseControl>"; Assert.AreEqual(expected, actual.ResponseFragment); }