private static void QueryEntitySetExecuteAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper) { contextWrapper.Configurations.ResponsePipeline .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading) .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart) .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd) .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading) .OnNestedResourceInfoEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink) .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized); IEnumerable <Customer> customers = null; IAsyncResult r = contextWrapper.BeginExecute <Customer>( new Uri("Customer", UriKind.Relative), result => { customers = contextWrapper.EndExecute <Customer>(result); }, null); while (!r.IsCompleted) { Thread.Sleep(1000); } foreach (Customer customer in customers) { PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer); } }
private static void QueryEntityInstanceExecuteAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper) { // contextWrapper.Context.UndeclaredPropertyBehavior = UndeclaredPropertyBehavior.Support; contextWrapper.Configurations.ResponsePipeline .OnEntryEnded(PipelineEventsTestsHelper.AddRemovePropertySpecialEmployeeEntry_Reading) .OnEntityMaterialized(PipelineEventsTestsHelper.AddEnumPropertySpecialEmployeeEntity_Materialized) .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomerEntity_Materialized); IEnumerable <SpecialEmployee> specialEmployees = null; IAsyncResult r = contextWrapper.BeginExecute <SpecialEmployee>( new Uri("Person(-10)", UriKind.Relative), result => { specialEmployees = contextWrapper.EndExecute <SpecialEmployee>(result); }, null); while (!r.IsCompleted) { Thread.Sleep(1000); } SpecialEmployee specialEmployee = specialEmployees.Single(); Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", specialEmployee.CarsLicensePlate, "Unexpected CarsLicensePlate"); Assert.AreEqual(1, specialEmployee.BonusLevel, "Unexpected BonusLevel"); }
private static void AddObjectSetLinkTestAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper) { // These delegates are invoked when the client sends a single request for AddObject+SetLink contextWrapper.Configurations.RequestPipeline .OnNestedResourceInfoStarting(PipelineEventsTestsHelper.ModifyNavigationLink_WritingStart) .OnNestedResourceInfoEnding(PipelineEventsTestsHelper.ModifyNavigationLink_WritingEnd) .OnEntityReferenceLink(PipelineEventsTestsHelper.ModifyReferenceLink); Customer customer = PipelineEventsTestsHelper.CreateNewCustomer(1300); Customer customer2 = PipelineEventsTestsHelper.CreateNewCustomer(1301); Customer customer3 = PipelineEventsTestsHelper.CreateNewCustomer(1302); Customer customer4 = PipelineEventsTestsHelper.CreateNewCustomer(1303); contextWrapper.AddObject("Customer", customer); contextWrapper.AddObject("Customer", customer2); contextWrapper.AddObject("Customer", customer3); contextWrapper.AddObject("Customer", customer4); IAsyncResult r1 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r1.IsCompleted) { Thread.Sleep(1000); } Order order = PipelineEventsTestsHelper.CreateNewOrder(1300); contextWrapper.AddObject("Order", order); contextWrapper.SetLink(order, "Customer", customer); IAsyncResult r2 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r2.IsCompleted) { Thread.Sleep(1000); } Assert.AreEqual(1300, order.OrderId, "OrderId should not be altered in the pipeline delegates"); Customer relatedCustomer = null; IAsyncResult r3 = contextWrapper.BeginExecute <Customer>( new Uri("Order(1300)/Customer", UriKind.Relative), result => { relatedCustomer = contextWrapper.EndExecute <Customer>(result).Single(); }, null); while (!r3.IsCompleted) { Thread.Sleep(1000); } Assert.AreEqual(1302, relatedCustomer.CustomerId, "Associated CustomerId should be altered in the pipeline delegates"); contextWrapper.DeleteObject(customer); contextWrapper.DeleteObject(customer2); contextWrapper.DeleteObject(customer3); contextWrapper.DeleteObject(customer4); contextWrapper.DeleteObject(order); IAsyncResult r4 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r4.IsCompleted) { Thread.Sleep(1000); } }
private static void QueryEntitySetExecuteAsync(DataServiceContextWrapper<DefaultContainer> contextWrapper) { contextWrapper.Configurations.ResponsePipeline .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading) .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart) .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd) .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading) .OnNavigationLinkEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink) .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized); // cover this for Json if (contextWrapper.Format.ODataFormat == ODataFormat.Atom) { contextWrapper.Configurations.ResponsePipeline.OnNavigationLinkStarted( PipelineEventsTestsHelper.ModifyLinkName_ReadingNavigationLink); } IEnumerable<Customer> customers = null; IAsyncResult r = contextWrapper.BeginExecute<Customer>( new Uri("Customer", UriKind.Relative), result => { customers = contextWrapper.EndExecute<Customer>(result); }, null); while (!r.IsCompleted) { Thread.Sleep(1000); } foreach (Customer customer in customers) { PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer); } }
private static void AddObjectSetLinkTestAsync(DataServiceContextWrapper<DefaultContainer> contextWrapper) { // These delegates are invoked when the client sends a single request for AddObject+SetLink contextWrapper.Configurations.RequestPipeline .OnNavigationLinkStarting(PipelineEventsTestsHelper.ModifyNavigationLink_WritingStart) .OnNavigationLinkEnding(PipelineEventsTestsHelper.ModifyNavigationLink_WritingEnd) .OnEntityReferenceLink(PipelineEventsTestsHelper.ModifyReferenceLink); Customer customer = PipelineEventsTestsHelper.CreateNewCustomer(1300); Customer customer2 = PipelineEventsTestsHelper.CreateNewCustomer(1301); Customer customer3 = PipelineEventsTestsHelper.CreateNewCustomer(1302); Customer customer4 = PipelineEventsTestsHelper.CreateNewCustomer(1303); contextWrapper.AddObject("Customer", customer); contextWrapper.AddObject("Customer", customer2); contextWrapper.AddObject("Customer", customer3); contextWrapper.AddObject("Customer", customer4); IAsyncResult r1 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r1.IsCompleted) { Thread.Sleep(1000); } Order order = PipelineEventsTestsHelper.CreateNewOrder(1300); contextWrapper.AddObject("Order", order); contextWrapper.SetLink(order, "Customer", customer); IAsyncResult r2 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r2.IsCompleted) { Thread.Sleep(1000); } Assert.AreEqual(1300, order.OrderId, "OrderId should not be altered in the pipeline delegates"); Customer relatedCustomer = null; IAsyncResult r3 = contextWrapper.BeginExecute<Customer>( new Uri("Order(1300)/Customer", UriKind.Relative), result => { relatedCustomer = contextWrapper.EndExecute<Customer>(result).Single(); }, null); while (!r3.IsCompleted) { Thread.Sleep(1000); } Assert.AreEqual(1302, relatedCustomer.CustomerId, "Associated CustomerId should be altered in the pipeline delegates"); contextWrapper.DeleteObject(customer); contextWrapper.DeleteObject(customer2); contextWrapper.DeleteObject(customer3); contextWrapper.DeleteObject(customer4); contextWrapper.DeleteObject(order); IAsyncResult r4 = contextWrapper.BeginSaveChanges( result => { contextWrapper.EndSaveChanges(result); }, null); while (!r4.IsCompleted) { Thread.Sleep(1000); } }
private static void QueryEntityInstanceExecuteAsync(DataServiceContextWrapper<DefaultContainer> contextWrapper) { contextWrapper.Context.IgnoreMissingProperties = true; contextWrapper.Configurations.ResponsePipeline .OnEntryEnded(PipelineEventsTestsHelper.AddRemovePropertySpecialEmployeeEntry_Reading) .OnEntityMaterialized(PipelineEventsTestsHelper.AddEnumPropertySpecialEmployeeEntity_Materialized) .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomerEntity_Materialized); IEnumerable<SpecialEmployee> specialEmployees = null; IAsyncResult r = contextWrapper.BeginExecute<SpecialEmployee>( new Uri("Person(-10)", UriKind.Relative), result => { specialEmployees = contextWrapper.EndExecute<SpecialEmployee>(result); }, null); while (!r.IsCompleted) { Thread.Sleep(1000); } SpecialEmployee specialEmployee = specialEmployees.Single(); Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", specialEmployee.CarsLicensePlate, "Unexpected CarsLicensePlate"); Assert.AreEqual(1, specialEmployee.BonusLevel, "Unexpected BonusLevel"); }