Exemplo n.º 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());
        }
Exemplo n.º 2
0
        private static void VerifyChangeRequest(String mediaType,
                                                ChangeRequest changeRequest,
                                                bool recurse)
        {
            Assert.IsNotNull(changeRequest);

            Uri      aboutURI         = changeRequest.GetAbout();
            DateTime?createdDate      = changeRequest.GetCreated();
            String   identifierString = changeRequest.GetIdentifier();
            DateTime?modifiedDate     = changeRequest.GetModified();

            Uri[] rdfTypesURIs       = changeRequest.GetRdfTypes();
            Uri   serviceProviderURI = changeRequest.GetServiceProvider();

            Assert.IsNotNull(aboutURI);
            Assert.IsNotNull(createdDate);
            Assert.IsNotNull(identifierString);
            Assert.IsNotNull(modifiedDate);
            Assert.IsNotNull(rdfTypesURIs);
            Assert.IsNotNull(serviceProviderURI);

            Assert.IsTrue(aboutURI.ToString().EndsWith(identifierString));
            Assert.IsTrue(modifiedDate.Equals(createdDate) || modifiedDate > createdDate);
            Assert.IsTrue(rdfTypesURIs.Contains(new Uri(Constants.TYPE_CHANGE_REQUEST)));

            if (recurse)
            {
                OslcRestClient aboutOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                        aboutURI,
                                                                        mediaType);

                VerifyChangeRequest(mediaType,
                                    aboutOSLCRestClient.GetOslcResource <ChangeRequest>(),
                                    false);

                OslcRestClient serviceProviderOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                                  serviceProviderURI,
                                                                                  mediaType);

                ServiceProvider serviceProvider = serviceProviderOSLCRestClient.GetOslcResource <ServiceProvider>();

                Assert.IsNotNull(serviceProvider);
            }
        }