public void ToStringSerialisesAllValues()
 {
     ProjectStatus projectStatus = new ProjectStatus("test project", IntegrationStatus.Success, DateTime.Now);
     ProjectStatusResponse response = new ProjectStatusResponse();
     response.ErrorMessages.Add(new ErrorMessage("Error 1"));
     response.ErrorMessages.Add(new ErrorMessage("Error 2"));
     response.RequestIdentifier = "request";
     response.Result = ResponseResult.Success;
     response.Timestamp = DateTime.Now;
     response.Projects.Add(projectStatus);
     string actual = response.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<projectStatusResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" result=\"{1}\">" +
         "<error>Error 1</error>" +
         "<error>Error 2</error>" +
         "<project showForceBuildButton=\"true\" showStartStopButton=\"true\" serverName=\"{5}\" status=\"Running\" buildStatus=\"Success\" name=\"test project\" " +
         "queuePriority=\"0\" lastBuildDate=\"{3:yyyy-MM-ddTHH:mm:ss.FFFFFFF}\" nextBuildTime=\"{4:yyyy-MM-ddTHH:mm:ss.FFFFFFF}\">" + 
         "<activity type=\"Sleeping\" />" +
         "</project>" + 
         "</projectStatusResponse>",
         response.RequestIdentifier,
         response.Result,
         response.Timestamp,
         projectStatus.LastBuildDate,
         projectStatus.NextBuildTime,
         Environment.MachineName);
     Assert.AreEqual(expected, actual);
 }
 public void InitialiseNewResponseSetsTheDefaultValues()
 {
     DateTime now = DateTime.Now;
     ProjectStatusResponse response = new ProjectStatusResponse();
     Assert.AreEqual(ResponseResult.Unknown, response.Result, "Result wasn't set to failure");
     Assert.IsTrue((now <= response.Timestamp), "Timestamp was not set");
 }
 public void InitialiseResponseFromRequestSetsTheDefaultValues()
 {
     DateTime now = DateTime.Now;
     ServerRequest request = new ServerRequest();
     ProjectStatusResponse response = new ProjectStatusResponse(request);
     Assert.AreEqual(ResponseResult.Unknown, response.Result, "Result wasn't set to failure");
     Assert.AreEqual(request.Identifier, response.RequestIdentifier, "RequestIdentifier wasn't set to the identifier of the request");
     Assert.IsTrue((now <= response.Timestamp), "Timestamp was not set");
 }
 public void GetProjectStatusSendsRequest()
 {
     ProjectStatus status = new ProjectStatus("Test project", IntegrationStatus.Success, DateTime.Now);
     ProjectStatusResponse response = new ProjectStatusResponse();
     response.Result = ResponseResult.Success;
     response.Projects.Add(status);
     CruiseServerClient client = new CruiseServerClient(
         new ServerStub("GetProjectStatus", typeof(ServerRequest), response));
     client.GetProjectStatus();
 }
 public void ToStringSerialisesDefaultValues()
 {
     ProjectStatusResponse response = new ProjectStatusResponse();
     string actual = response.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<projectStatusResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{1:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" result=\"{0}\" />",
         response.Result,
         response.Timestamp);
     Assert.AreEqual(expected, actual);
 }
 public void InitialiseResponseFromResponseSetsTheDefaultValues()
 {
     DateTime now = DateTime.Now;
     ProjectStatusResponse response1 = new ProjectStatusResponse();
     response1.Result = ResponseResult.Success;
     response1.RequestIdentifier = "original id";
     response1.Timestamp = DateTime.Now.AddMinutes(-1);
     ProjectStatusResponse response2 = new ProjectStatusResponse(response1);
     Assert.AreEqual(ResponseResult.Success, response2.Result, "Result wasn't set to failure");
     Assert.AreEqual("original id", response2.RequestIdentifier, "RequestIdentifier wasn't set to the identifier of the request");
     Assert.IsTrue((response1.Timestamp == response2.Timestamp), "Timestamp was not set");
 }
        public void GetProjectStatusThrowsExceptionOnFailure()
        {
            ProjectStatusResponse response = new ProjectStatusResponse();
            IServerConnection connection = mocks.DynamicMock<IServerConnection>();
            SetupResult.For(connection.SendMessage("GetProjectStatus", null))
                .IgnoreArguments()
                .Return(response);
            mocks.ReplayAll();

            CruiseServerClient client = new CruiseServerClient(connection);
            Assert.That(delegate { client.GetProjectStatus(); },
                        Throws.TypeOf<CommunicationsException>());
        }
        public void GetProjectStatusReturnsProjects()
        {
            ProjectStatus status = new ProjectStatus("Test project", IntegrationStatus.Success, DateTime.Now);
            ProjectStatusResponse response = new ProjectStatusResponse();
            response.Result = ResponseResult.Success;
            response.Projects.Add(status);
            IServerConnection connection = mocks.DynamicMock<IServerConnection>();
            SetupResult.For(connection.SendMessage("GetProjectStatus", null))
                .IgnoreArguments()
                .Return(response);
            mocks.ReplayAll();

            CruiseServerClient client = new CruiseServerClient(connection);
            ProjectStatus[] results = client.GetProjectStatus();
            Assert.AreEqual(1, results.Length);
            Assert.AreEqual(status, results[0]);
        }
Esempio n. 9
0
 /// <summary>
 /// Gets information about the last build status, current activity and project name.
 /// for all projects on a cruise server
 /// </summary>
 public virtual ProjectStatusResponse GetProjectStatus(ServerRequest request)
 {
     ProjectStatus[] data = null;
     ProjectStatusResponse response = new ProjectStatusResponse(RunServerRequest(request,
         null,
         null,
         delegate
         {
             data = integrationQueueManager.GetProjectStatuses();
             if (request.SessionToken != SecurityOverride.SessionIdentifier)
             {
                 data = this.FilterProjects(request.SessionToken, data);
             }
         }));
     if (data != null) response.Projects.AddRange(data);
     return response;
 }
Esempio n. 10
0
 /// <summary>
 /// Gets information about the last build status, current activity and project name.
 /// for all projects on a cruise server
 /// </summary>
 public virtual ProjectStatusResponse GetProjectStatus(ServerRequest request)
 {
     ProjectStatus[] data = null;
     ProjectStatusResponse response = new ProjectStatusResponse(RunServerRequest(request,
         null,
         null,
         delegate(ServerRequest arg)
         {
             data = integrationQueueManager.GetProjectStatuses();
             data = FilterProjects(request.SessionToken, data);
         }));
     if (data != null) response.Projects.AddRange(data);
     return response;
 }