Пример #1
0
        protected void TestUpdate(String mediaType)
        {
            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               CREATED_CHANGE_REQUEST_URI,
                                                               mediaType);

            ChangeRequest changeRequest = oslcRestClient.GetOslcResource <ChangeRequest>();

            VerifyChangeRequest(mediaType,
                                changeRequest,
                                true);

            Assert.IsNull(changeRequest.IsApproved());
            Assert.IsNull(changeRequest.GetCloseDate());

            DateTime closeDate = DateTime.Now;

            changeRequest.SetApproved(true);
            changeRequest.SetCloseDate(closeDate);

            HttpResponseMessage clientResponse = oslcRestClient.UpdateOslcResourceReturnClientResponse(changeRequest);

            Assert.IsNotNull(clientResponse);
            Assert.AreEqual(HttpStatusCode.OK, clientResponse.StatusCode);

            ChangeRequest updatedChangeRequest = oslcRestClient.GetOslcResource <ChangeRequest>();

            VerifyChangeRequest(mediaType,
                                updatedChangeRequest,
                                true);

            Assert.AreEqual(changeRequest.GetAbout(), updatedChangeRequest.GetAbout());
            Assert.AreEqual(true, updatedChangeRequest.IsApproved());
            Assert.AreEqual(closeDate.ToShortDateString() + " - " + closeDate.ToShortTimeString(),
                            updatedChangeRequest.GetCloseDate().Value.ToShortDateString() + " - " + updatedChangeRequest.GetCloseDate().Value.ToShortTimeString());
            Assert.IsFalse(changeRequest.GetModified().Equals(updatedChangeRequest.GetModified()));
            Assert.IsTrue(updatedChangeRequest.GetModified() > updatedChangeRequest.GetCreated());
        }