public void QueryWithBothMinimalAndFullMetadataShouldNotCauseDuplicateIdentities() { // Repro for: EntityDescriptor identity/links key order changes for json DataServiceContext using (TestUtil.MetadataCacheCleaner()) using (TestWebRequest request = TestWebRequest.CreateForInProcessWcf()) { // using the row-based context because it intentionally puts OrderDetail's key properties in non-alphabetical order in the OM. request.DataServiceType = typeof(CustomRowBasedContext); request.StartService(); DataServiceContext ctx = new DataServiceContext(request.ServiceRoot, ODataProtocolVersion.V4); JsonLightTestUtil.ConfigureContextForJsonLight(ctx); ConfigureContextForSendingRequest2Verification(ctx); var firstOrderDetail = ctx.CreateQuery <OrderDetail>("OrderDetails").First(); var firstOrderDetailProjected = ctx.CreateQuery <OrderDetail>("OrderDetails").Select(od => new OrderDetail { Quantity = od.Quantity }).First(); Assert.IsNotNull(firstOrderDetail); Assert.IsNotNull(firstOrderDetailProjected); Assert.AreEqual(1, ctx.Entities.Count); } }
private static void RunClientIntegrationTestWithMergeOption(Action <DataServiceContext> executeAndVerify, MergeOption mergeOption, Action <DataServiceConfiguration, Type> pageSizeCustomizer) { using (TestUtil.MetadataCacheCleaner()) using (OpenWebDataServiceHelper.PageSizeCustomizer.Restore()) using (TestWebRequest request = TestWebRequest.CreateForInProcessWcf()) { OpenWebDataServiceHelper.PageSizeCustomizer.Value = pageSizeCustomizer; request.DataServiceType = typeof(CustomDataContext); request.ForceVerboseErrors = true; request.StartService(); DataServiceContext ctx = new DataServiceContext(request.ServiceRoot, ODataProtocolVersion.V4); ctx.MergeOption = mergeOption; JsonLightTestUtil.ConfigureContextForJsonLight(ctx); ConfigureContextForSendingRequest2Verification(ctx); executeAndVerify(ctx); } }
private static void RunClientIntegrationTestWithNamedStreams(Action <DataServiceContext> executeAndVerify, MergeOption mergeOption) { DSPServiceDefinition service = NamedStreamService.SetUpNamedStreamService(); // Configure one of the named streams on each type to have a different ReadStreamUri than the default, so we can verify it's correctly picked up and not built using conventions ConfigureReadStreamUri(service, "MySet1", "EntityWithNamedStreams", "Stream1"); ConfigureReadStreamUri(service, "MySet2", "EntityWithNamedStreams1", "RefStream1"); ConfigureReadStreamUri(service, "MySet3", "EntityWithNamedStreams2", "ColStream"); using (TestWebRequest request = service.CreateForInProcessWcf()) { request.StartService(); DataServiceContext ctx = new DataServiceContext(request.ServiceRoot, ODataProtocolVersion.V4); ctx.MergeOption = mergeOption; JsonLightTestUtil.ConfigureContextForJsonLight(ctx); ConfigureContextForSendingRequest2Verification(ctx); executeAndVerify(ctx); } }
public void SimpleQueryWithOpenTypes() { using (TestUtil.MetadataCacheCleaner()) using (TestWebRequest request = TestWebRequest.CreateForInProcessWcf()) using (OpenWebDataServiceHelper.EnableAccess.Restore()) { OpenWebDataServiceHelper.EnableAccess.Value = new List <string> { "AstoriaUnitTests.Stubs.Address" }; request.DataServiceType = typeof(CustomRowBasedOpenTypesContext); request.ForceVerboseErrors = true; request.StartService(); DataServiceContext ctx = new DataServiceContext(request.ServiceRoot, ODataProtocolVersion.V4); JsonLightTestUtil.ConfigureContextForJsonLight(ctx); var query = ctx.CreateQuery <Customer>("Customers"); var customer = query.First(); // Basic sanity check to be sure product was materialized with data values and links Assert.IsFalse(String.IsNullOrEmpty(customer.Name), "Expected customer to have a non-null or empty materialized value."); } }