private static void QueryEntityInstance(DataServiceContextWrapper <DefaultContainer> contextWrapper) { // contextWrapper.Context.UndeclaredPropertyBehavior = UndeclaredPropertyBehavior.Support; contextWrapper.Configurations.ResponsePipeline .OnEntryEnded(PipelineEventsTestsHelper.AddRemovePropertySpecialEmployeeEntry_Reading) .OnEntityMaterialized(PipelineEventsTestsHelper.AddEnumPropertySpecialEmployeeEntity_Materialized) .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomerEntity_Materialized); var specialEmployee = contextWrapper.CreateQuery <Person>("Person").Where(p => p.PersonId == -10).Single() as SpecialEmployee; EntityDescriptor descriptor = contextWrapper.GetEntityDescriptor(specialEmployee); Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", specialEmployee.CarsLicensePlate, "Unexpected CarsLicensePlate"); Assert.AreEqual(1, specialEmployee.BonusLevel, "Unexpected BonusLevel"); specialEmployee = contextWrapper.Execute <SpecialEmployee>(new Uri("Person(-10)", UriKind.Relative)).Single(); Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", specialEmployee.CarsLicensePlate, "Unexpected CarsLicensePlate"); Assert.AreEqual(1, specialEmployee.BonusLevel, "Unexpected BonusLevel"); DataServiceRequest[] requests = new DataServiceRequest[] { contextWrapper.CreateQuery <Person>("Person"), contextWrapper.CreateQuery <Customer>("Customer"), }; DataServiceResponse responses = contextWrapper.ExecuteBatch(requests); bool personVerified = false; bool customerVerified = false; foreach (QueryOperationResponse response in responses) { foreach (object p in response) { var specialEmployee1 = p as SpecialEmployee; Customer c = p as Customer; if (specialEmployee1 != null) { Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", specialEmployee1.CarsLicensePlate, "Unexpected CarsLicensePlate"); Assert.AreEqual(1, specialEmployee1.BonusLevel, "Unexpected BonusLevel"); personVerified = true; } if (c != null) { Assert.IsTrue(c.Name.EndsWith("ModifyPropertyValueCustomerEntity_Materialized"), "Unexpected primitive property"); Assert.IsTrue(c.Auditing.ModifiedBy.Equals("ModifyPropertyValueCustomerEntity_Materialized"), "Unexpected complex property"); Assert.IsTrue(c.PrimaryContactInfo.EmailBag.Contains("ModifyPropertyValueCustomerEntity_Materialized"), "Unexpected collection property"); customerVerified = true; } } } Assert.IsTrue(personVerified && customerVerified, "Some inner request does not completed correctly"); }
private static void LoadPropertyTest(DataServiceContextWrapper <DefaultContainer> contextWrapper) { // contextWrapper.Context.UndeclaredPropertyBehavior = UndeclaredPropertyBehavior.Support; SpecialEmployee specialEmployee = contextWrapper.Execute <SpecialEmployee>(new Uri("Person(-10)", UriKind.Relative)).Single(); contextWrapper.Configurations.ResponsePipeline.OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryId_Reading); QueryOperationResponse <Car> cars = contextWrapper.LoadProperty(specialEmployee, "Car") as QueryOperationResponse <Car>; foreach (Car car in cars) { EntityDescriptor descriptor = contextWrapper.GetEntityDescriptor(car); Assert.IsTrue(descriptor.Identity.OriginalString.Contains("ModifyEntryId"), "Wrong Id"); } }
private static void ExpandNullEntry(DataServiceContextWrapper <DefaultContainer> contextWrapper) { contextWrapper.Configurations.ResponsePipeline .OnEntryStarted(PipelineEventsTestsHelper.ModifyNullableEntryId_Reading) .OnEntryEnded(PipelineEventsTestsHelper.ModifyNullalbeEntryEditLink_ReadingEnd); var entries = contextWrapper.CreateQuery <License>("License").Expand("Driver").Where(c => c.Name == "3").ToArray(); Assert.IsTrue(entries.Count() == 1, "Wrong count"); var license = entries[0]; Assert.IsNull(license.Driver, "Driver is not null"); EntityDescriptor descriptor = contextWrapper.GetEntityDescriptor(license); Assert.IsTrue(descriptor.Identity.OriginalString.Contains("ModifyEntryId"), "Wrong Id"); Assert.IsTrue(descriptor.EditLink.AbsoluteUri.Contains("ModifyEntryEditLink"), "Wrong EditLink"); }
public static void VerifyModfiedCustomerEntry(DataServiceContextWrapper <DefaultContainer> contextWrapper, Customer e) { Assert.IsTrue(e.Name.EndsWith("ModifyPropertyValueCustomer_Materialized"), "Property value not updated"); EntityDescriptor descriptor = contextWrapper.GetEntityDescriptor(e); Assert.IsTrue(descriptor.Identity.OriginalString.Contains("ModifyEntryId"), "Wrong Id"); Assert.IsTrue(descriptor.EditLink.AbsoluteUri.Contains("http://myeditlink/ModifyEntryEditLink"), "Wrong EditLink"); Assert.IsTrue(descriptor.OperationDescriptors.Where(op => op.Title == "ModifyEntryAction").Any(), "Action not added"); foreach (var linkInfo in descriptor.LinkInfos) { if (linkInfo.NavigationLink != null) { // In Jsonlight, navigation link is calculated using edit link after the reading delegates Assert.IsTrue(linkInfo.NavigationLink.AbsoluteUri.StartsWith("http://myeditlink/ModifyEntryEditLink"), "Wrong navigation link"); Assert.AreEqual("http://modifyassociationlinkurl/", linkInfo.AssociationLink.AbsoluteUri, "AssociationLink not updated"); } } }
public static void VerifyModfiedCustomerEntry(DataServiceContextWrapper<DefaultContainer> contextWrapper, Customer e) { Assert.IsTrue(e.Name.EndsWith("ModifyPropertyValueCustomer_Materialized"), "Property value not updated"); EntityDescriptor descriptor = contextWrapper.GetEntityDescriptor(e); Assert.IsTrue(descriptor.Identity.OriginalString.Contains("ModifyEntryId"), "Wrong Id"); Assert.IsTrue(descriptor.EditLink.AbsoluteUri.Contains("http://myeditlink/ModifyEntryEditLink"), "Wrong EditLink"); Assert.IsTrue(descriptor.OperationDescriptors.Where(op => op.Title == "ModifyEntryAction").Any(), "Action not added"); foreach (var linkInfo in descriptor.LinkInfos) { if (contextWrapper.Format.ODataFormat == ODataFormat.Atom) { Assert.IsTrue(linkInfo.Name.EndsWith("ModifyLinkName"), "Link name not updated"); } if (contextWrapper.Format.ODataFormat == ODataFormat.Json) { // In Jsonlight, navigation link is calculated using edit link after the reading delegates Assert.IsTrue(linkInfo.NavigationLink.AbsoluteUri.StartsWith("http://myeditlink/ModifyEntryEditLink"), "Wrong navigation link"); } Assert.AreEqual("http://modifyassociationlinkurl/", linkInfo.AssociationLink.AbsoluteUri, "AssociationLink not updated"); } }