public void RequestUriLinksCollectionTest() { UnitTestsUtil.VerifyPayload("/Customers(2)/Orders/$ref", typeof(CustomDataContext), UnitTestsUtil.JsonLightMimeType, null, new string[] { String.Format("/{1}/value/{0}/{1}/odata.id[text()='http://host/Orders(2)']", JsonValidator.ArrayString, JsonValidator.ObjectString), String.Format("/{1}/value/{0}/{1}/odata.id[text()='http://host/Orders(102)']", JsonValidator.ArrayString, JsonValidator.ObjectString), String.Format("count(/{1}/value/{0}/{1}//odata.id)=2", JsonValidator.ArrayString, JsonValidator.ObjectString) }); }
public void RequestUriProjectPropertyTest() { UnitTestsUtil.VerifyPayload("/Customers(1)/Name", typeof(CustomDataContext), null, new string[] { "/cdc:Name", "/cdc:Name[text()='Customer 1']" }, new string[] { String.Format("/{0}/Name[text()='Customer 1']", JsonValidator.ObjectString) }, new string[0]); }
public void RequestUriLinksReferenceTest() { UnitTestsUtil.VerifyPayload("/Customers(1)/BestFriend/$ref", typeof(CustomDataContext), UnitTestsUtil.JsonLightMimeType, null, new string[] { String.Format("/{0}/odata.id[text()='http://host/Customers(0)']", JsonValidator.ObjectString), String.Format("count(//{0}/odata.id)=1", JsonValidator.ObjectString) }); }
public void RequestUriResourceSetPropertyTest() { UnitTestsUtil.VerifyPayload("/Customers(0)/Orders", typeof(CustomDataContext), null, new string[] { "/cdc:Orders", "/cdc:Orders/cdc:Order" }, new string[] { String.Format("/{0}", JsonValidator.ArrayString), JsonValidator.GetJsonTypeXPath(typeof(Order), true /*isArray*/) }, new string[0]); UnitTestsUtil.VerifyInvalidUri("/Customers!1000/Orders", typeof(CustomDataContext)); UnitTestsUtil.VerifyInvalidUri("/Customers(1)/Orders(10000)", typeof(CustomDataContext)); }
public void RequestUriComplexPropertyTest() { UnitTestsUtil.VerifyPayload("/Customers(0)/Address", typeof(CustomDataContext), null, new string[] { "/cdc:Address" }, new string[] { String.Format("/{0}/Address/StreetAddress[text()='Line1']", JsonValidator.ObjectString), String.Format("/{0}/Address/City[text()='Redmond']", JsonValidator.ObjectString) }, new string[0]); UnitTestsUtil.VerifyPayload("/Customers(0)/Address/StreetAddress", typeof(CustomDataContext), null, new string[] { "/cdc:Line1" }, new string[] { String.Format("/{0}/StreetAddress[text()='Line1']", JsonValidator.ObjectString) }, new string[0]); }
public void RequestUriResourceKeySimpleTest() { UnitTestsUtil.VerifyPayload("/Customers(1)", typeof(CustomDataContext), null, new string[] { "/cdc:Customer", "/cdc:Customer/cdc:ID[text()='1']", "count(//cdc:Customer)=1" }, new string[] { JsonValidator.GetJsonTypeXPath(typeof(CustomerWithBirthday), false /*isArray*/), String.Format("/{0}/ID[text()='1']", JsonValidator.ObjectString), String.Format("count(//{0})=1", JsonValidator.ObjectString) }, new string[0]); }
public void RequestUriResourceSetPropertyTest() { Func <Hashtable, XmlDocument, bool> testCallBack = (values, document) => { string responseFormat = (string)values["ResponseFormat"]; string xPath; if (responseFormat == UnitTestsUtil.JsonLightMimeType) { xPath = String.Format("/{0}/{1}/ID", JsonValidator.ArrayString, JsonValidator.ObjectString); } else { Assert.IsTrue(responseFormat == UnitTestsUtil.AtomFormat, "unexpected format"); xPath = "/atom:feed/atom:entry/atom:content/adsm:properties/ads:ID"; } XmlElement order = (XmlElement)document.SelectSingleNode(xPath, TestUtil.TestNamespaceManager); using (TestWebRequest request = TestWebRequest.CreateForLocation(WebServerLocation.InProcess)) { request.RequestUriString = "/Customers(0)/Orders(" + order.InnerText + ")"; request.Accept = responseFormat; request.DataServiceType = typeof(CustomDataContext); request.SendRequest(); UnitTestsUtil.VerifyXPaths(request.GetResponseStream(), responseFormat, new string[] { "/cdc:Order" }, new string[] { JsonValidator.GetJsonTypeXPath(typeof(Order), false /*isArray*/) }, new string[0]); return(true); } }; UnitTestsUtil.VerifyPayload("/Customers(0)/Orders", typeof(CustomDataContext), testCallBack, new string[] { "/cdc:Orders", "/cdc:Orders/cdc:Order" }, new string[] { String.Format("/{0}", JsonValidator.ArrayString), JsonValidator.GetJsonTypeXPath(typeof(Order), true /*isArray*/) }, new string[0]); // TODO: When this is fixed, we should uncomment this test cases //UnitTestsUtil.VerifyInvalidUri("/Customers!1000/Orders", typeof(CustomDataContext)); UnitTestsUtil.VerifyInvalidUri("/Customers(1)/Orders(10000)", typeof(CustomDataContext)); }
public void RequestUriResourcePropertyTest() { UnitTestsUtil.VerifyInvalidUri("/Customers(1000)/BestFriend", typeof(CustomDataContext)); UnitTestsUtil.VerifyPayload("/Customers(2)/BestFriend", typeof(CustomDataContext), null, new string[] { "/cdc:BestFriend", "/cdc:BestFriend/web3s:ID[text()='1']" }, new string[] { String.Format("/{0}", JsonValidator.ObjectString), String.Format("/{0}/ID[text()='1']", JsonValidator.ObjectString) }, new string[0]); ServiceModelData.Northwind.EnsureDependenciesAvailable(); UnitTestsUtil.VerifyPayload("/Territories", typeof(NorthwindContext), null, new string[] { "//nc:Territories/web3s:ID" }, new string[] { String.Format("/{0}/{1}/TerritoryID[text()='01581']", JsonValidator.ArrayString, JsonValidator.ObjectString), String.Format("count(//{0})>10", JsonValidator.ObjectString) }, new string[0]); }