Exemple #1
0
            public void DeleteUsingAnyValueForIfMatch()
            {
                using (CustomDataContext.CreateChangeScope())
                {
                    Type contextType   = typeof(CustomDataContext);
                    var  ifMatchHeader = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("If-Match", "*") };

                    // Directly deleting a top level entity
                    UnitTestsUtil.SendRequestAndVerifyXPath(null, "/Customers(0)", null, contextType, null, "DELETE", ifMatchHeader, false);

                    // Deleting a deep entity
                    UnitTestsUtil.SendRequestAndVerifyXPath(null, "/Customers(2)/BestFriend", null, contextType, null, "DELETE", ifMatchHeader, false);
                }
            }
Exemple #2
0
            public void GetNullPrimitiveValueWithAnyValueForETag()
            {
                using (CustomDataContext.CreateChangeScope())
                {
                    Type contextType = typeof(CustomDataContext);

                    var ifMatchHeader = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("If-Match", "*") };

                    // Set the name property to null
                    UnitTestsUtil.SendRequestAndVerifyXPath(null, "/Customers(1)/Name/$value", null, contextType, UnitTestsUtil.JsonLightMimeType, "DELETE", ifMatchHeader, false);

                    // Both should work fine since the etag is of Customers(1)
                    UnitTestsUtil.SendRequestAndVerifyXPath(null, "/Customers(1)/Name", null, contextType, UnitTestsUtil.JsonLightMimeType, "GET", ifMatchHeader, true);
                    VerifyStatusCode("/Customers(1)/Name", UnitTestsUtil.JsonLightMimeType, "*", contextType, (int)HttpStatusCode.NotModified);

                    // This should return 404
                    UnitTestsUtil.VerifyInvalidRequest(null, "/Customers(1)/Name/$value", contextType, null, "GET", (int)HttpStatusCode.NotFound, ifMatchHeader);
                    VerifyStatusCode("/Customers(1)/Name/$value", UnitTestsUtil.MimeTextPlain, "*", contextType, (int)HttpStatusCode.NotModified);
                }
            }