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\" />" +
                                            "<parameters />" +
                                            "</project>" +
                                            "</projectStatusResponse>",
                                            response.RequestIdentifier,
                                            response.Result,
                                            response.Timestamp,
                                            projectStatus.LastBuildDate,
                                            projectStatus.NextBuildTime,
                                            Environment.MachineName);

            XDocument.Parse(actual).Should().BeEquivalentTo(XDocument.Parse(expected));
        }
Beispiel #2
0
        /// <summary>
        /// Gets information about the last build status, current activity and project name.
        /// for all projects on a cruise server
        /// </summary>
        public ProjectStatus[] GetProjectStatus()
        {
            ProjectStatusResponse resp = cruiseServer.GetProjectStatus(GenerateServerRequest());

            ValidateResponse(resp);
            return(resp.Projects.ToArray());
        }
        /// <summary>
        /// Gets information about the last build status, current activity and project name.
        /// for all projects on a cruise server
        /// </summary>
        public override ProjectStatus[] GetProjectStatus()
        {
            ProjectStatusResponse resp = ValidateResponse(
                connection.SendMessage("GetProjectStatus", GenerateServerRequest()))
                                         as ProjectStatusResponse;

            return(resp.Projects.ToArray());
        }
        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 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);

            XDocument.Parse(actual).Should().BeEquivalentTo(XDocument.Parse(expected));
        }
Beispiel #6
0
        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 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");

            var projects = new List <ProjectStatus>();

            response.Projects = projects;
            Assert.AreSame(projects, response.Projects);
        }
        public void GetProjectStatusThrowsExceptionOnFailure()
        {
            ProjectStatusResponse response   = new ProjectStatusResponse();
            IServerConnection     connection = mocks.Create <IServerConnection>().Object;

            Mock.Get(connection).Setup(_connection => _connection.SendMessage("GetProjectStatus", It.IsAny <ServerRequest>()))
            .Returns(response);

            CruiseServerClient client = new CruiseServerClient(connection);

            Assert.That(delegate { client.GetProjectStatus(); },
                        Throws.TypeOf <CommunicationsException>());
        }
        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");
        }
Beispiel #10
0
        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.Create <IServerConnection>().Object;

            Mock.Get(connection).Setup(_connection => _connection.SendMessage("GetProjectStatus", It.IsAny <ServerRequest>()))
            .Returns(response);

            CruiseServerClient client = new CruiseServerClient(connection);

            ProjectStatus[] results = client.GetProjectStatus();
            Assert.AreEqual(1, results.Length);
            Assert.AreEqual(status, results[0]);
        }
Beispiel #12
0
        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]);
        }