public void DerivedTypeSingletonClientTest() { TestClientContext = this.CreateWrappedContext <InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; //Query Singleton var queryCompany = TestClientContext.PublicCompany as DataServiceQuerySingle <Company>; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Singleton var loadLabourUnionAr = TestClientContext.BeginLoadProperty(company, "LabourUnion", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(loadLabourUnionAr); Assert.True((company as PublicCompany).LabourUnion != null); //Expand Navigation Property - Singleton queryCompany = TestClientContext.PublicCompany.Expand(c => (c as PublicCompany).Club) as DataServiceQuerySingle <Company>; queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.True((company as PublicCompany).Club != null); //Update Navigation property of derived Type - Singleton var labourUnion = (company as PublicCompany).LabourUnion; labourUnion.Name = "UpdatedLabourUnionName"; TestClientContext.UpdateRelatedObject(company, "LabourUnion", labourUnion); var updateRelatedObjectAr = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(updateRelatedObjectAr); //Projecton with Navigation property - singletonof derived type. var queryPublicCompany = TestClientContext.PublicCompany.Select(c => new PublicCompany { CompanyID = c.CompanyID, LabourUnion = (c as PublicCompany).LabourUnion }) as DataServiceQuerySingle <PublicCompany>; var queryPublicCompanyAr = queryPublicCompany.BeginGetValue(null, null).EnqueueWait(this); var publicCompany = queryPublicCompany.EndGetValue(queryPublicCompanyAr); Assert.True(publicCompany.LabourUnion != null); this.EnqueueTestComplete(); }
public void UpdateDerivedTypeNavigationOfContainedSingleEntity() { TestClientContext = this.CreateWrappedContext <InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; //Query Singleton var queryCompany = TestClientContext.PublicCompany; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Load Navigation Property //Single Enity var loadClubAr = TestClientContext.BeginLoadProperty(company, "Club", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(loadClubAr); Assert.True((company as PublicCompany).Club != null); //Updated Conatined Navigation Property - SingleEntity of derived type var club = (company as PublicCompany).Club; club.Name = "UpdatedClubName"; TestClientContext.UpdateRelatedObject(company, "Club", club); var updateRelatedObjectAr = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(updateRelatedObjectAr); //Projecton with Contained Navigation Property - Single Entity of derived type var queryPublicCompany = TestClientContext.PublicCompany.Select(c => new PublicCompany { CompanyID = c.CompanyID, Club = (c as PublicCompany).Club }) as DataServiceQuerySingle <PublicCompany>; var queryPublicCompany2Ar = queryPublicCompany.BeginGetValue(null, null).EnqueueWait(this); var publicCompany = queryPublicCompany.EndGetValue(queryPublicCompany2Ar); Assert.True(publicCompany.Club.Name == "UpdatedClubName"); this.EnqueueTestComplete(); }
public void SingletonQueryUpdateNavigationSingletonPropertyClientTest() { TestClientContext = this.CreateWrappedContext <InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; var queryCompany = TestClientContext.Company as DataServiceQuerySingle <Company>; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Query Singleton again with Execute var queryVipCustomerAr = TestClientContext.BeginExecute <Customer>(new Uri("VipCustomer", UriKind.Relative), null, null).EnqueueWait(this); var vipCustomer = TestClientContext.EndExecute <Customer>(queryVipCustomerAr).Single(); Assert.True(vipCustomer != null); //Update Singleton's Navigation property - Singleton vipCustomer.City = "UpdatedCity"; TestClientContext.UpdateRelatedObject(company, "VipCustomer", vipCustomer); var ar6 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar6); //Expand Navigation Property - Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand(c => c.VipCustomer); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.True(company.VipCustomer.City == "UpdatedCity"); //Update Navigation Property - Delete the Singleton navigation TestClientContext.SetLink(company, "VipCustomer", null); var ar7 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar7); //Expand Navigation Property using name- Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand("VipCustomer"); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.True(company.VipCustomer == null); //Update Navigation Property - Singleton TestClientContext.SetLink(company, "VipCustomer", vipCustomer); var ar8 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar8); //LoadProperty Navigation Property - Singleton company.VipCustomer = null; var ar13 = TestClientContext.BeginLoadProperty(company, "VipCustomer", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(ar13); Assert.True(company.VipCustomer != null); //Expand Navigation Property - Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand(c => c.VipCustomer); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.True(company.VipCustomer != null); //Query Singleton's Navigation Property - Singleton queryCompany = TestClientContext.Company.Select(c => new Company { CompanyID = c.CompanyID, VipCustomer = c.VipCustomer }) as DataServiceQuerySingle <Company>; queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.True(company.VipCustomer != null); this.EnqueueTestComplete(); }
public void DerivedTypeSingletonClientTest() { TestClientContext = this.CreateWrappedContext<InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; //Query Singleton var queryCompany = TestClientContext.PublicCompany as DataServiceQuerySingle<Company>; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Singleton var loadLabourUnionAr = TestClientContext.BeginLoadProperty(company, "LabourUnion", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(loadLabourUnionAr); Assert.IsTrue((company as PublicCompany).LabourUnion != null); //Expand Navigation Property - Singleton queryCompany = TestClientContext.PublicCompany.Expand(c => (c as PublicCompany).Club) as DataServiceQuerySingle<Company>; queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.IsTrue((company as PublicCompany).Club != null); //Update Navigation property of derived Type - Singleton var labourUnion = (company as PublicCompany).LabourUnion; labourUnion.Name = "UpdatedLabourUnionName"; TestClientContext.UpdateRelatedObject(company, "LabourUnion", labourUnion); var updateRelatedObjectAr = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(updateRelatedObjectAr); //Projecton with Navigation property - singletonof derived type. var queryPublicCompany = TestClientContext.PublicCompany.Select(c => new PublicCompany { CompanyID = c.CompanyID, LabourUnion = (c as PublicCompany).LabourUnion }) as DataServiceQuerySingle<PublicCompany>; var queryPublicCompanyAr = queryPublicCompany.BeginGetValue(null, null).EnqueueWait(this); var publicCompany = queryPublicCompany.EndGetValue(queryPublicCompanyAr); Assert.IsTrue(publicCompany.LabourUnion != null); this.EnqueueTestComplete(); }
public void UpdateDerivedTypeNavigationOfContainedSingleEntity() { TestClientContext = this.CreateWrappedContext<InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; //Query Singleton var queryCompany = TestClientContext.PublicCompany; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Load Navigation Property //Single Enity var loadClubAr = TestClientContext.BeginLoadProperty(company, "Club", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(loadClubAr); Assert.IsTrue((company as PublicCompany).Club != null); //Updated Conatined Navigation Property - SingleEntity of derived type var club = (company as PublicCompany).Club; club.Name = "UpdatedClubName"; TestClientContext.UpdateRelatedObject(company, "Club", club); var updateRelatedObjectAr = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(updateRelatedObjectAr); //Projecton with Contained Navigation Property - Single Entity of derived type var queryPublicCompany = TestClientContext.PublicCompany.Select(c => new PublicCompany { CompanyID = c.CompanyID, Club = (c as PublicCompany).Club }) as DataServiceQuerySingle<PublicCompany>; var queryPublicCompany2Ar = queryPublicCompany.BeginGetValue(null, null).EnqueueWait(this); var publicCompany = queryPublicCompany.EndGetValue(queryPublicCompany2Ar); Assert.IsTrue(publicCompany.Club.Name == "UpdatedClubName"); this.EnqueueTestComplete(); }
public void SingletonQueryUpdateNavigationSingletonPropertyClientTest() { TestClientContext = this.CreateWrappedContext<InMemoryEntities>().Context; TestClientContext.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges; var queryCompany = TestClientContext.Company as DataServiceQuerySingle<Company>; var queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); var company = queryCompany.EndGetValue(queryCompanyAr); //Query Singleton again with Execute var queryVipCustomerAr = TestClientContext.BeginExecute<Customer>(new Uri("VipCustomer", UriKind.Relative), null, null).EnqueueWait(this); var vipCustomer = TestClientContext.EndExecute<Customer>(queryVipCustomerAr).Single(); Assert.IsTrue(vipCustomer != null); //Update Singleton's Navigation property - Singleton vipCustomer.City = "UpdatedCity"; TestClientContext.UpdateRelatedObject(company, "VipCustomer", vipCustomer); var ar6 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar6); //Expand Navigation Property - Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand(c => c.VipCustomer); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.IsTrue(company.VipCustomer.City == "UpdatedCity"); //Update Navigation Property - Delete the Singleton navigation TestClientContext.SetLink(company, "VipCustomer", null); var ar7 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar7); //Expand Navigation Property using name- Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand("VipCustomer"); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.IsTrue(company.VipCustomer == null); //Update Navigation Property - Singleton TestClientContext.SetLink(company, "VipCustomer", vipCustomer); var ar8 = TestClientContext.BeginSaveChanges(null, null).EnqueueWait(this); TestClientContext.EndSaveChanges(ar8); //LoadProperty Navigation Property - Singleton company.VipCustomer = null; var ar13 = TestClientContext.BeginLoadProperty(company, "VipCustomer", null, null).EnqueueWait(this); TestClientContext.EndLoadProperty(ar13); Assert.IsTrue(company.VipCustomer != null); //Expand Navigation Property - Singleton company.VipCustomer = null; queryCompany = TestClientContext.Company.Expand(c => c.VipCustomer); queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.IsTrue(company.VipCustomer != null); //Query Singleton's Navigation Property - Singleton queryCompany = TestClientContext.Company.Select(c => new Company { CompanyID = c.CompanyID, VipCustomer = c.VipCustomer }) as DataServiceQuerySingle<Company>; queryCompanyAr = queryCompany.BeginGetValue(null, null).EnqueueWait(this); company = queryCompany.EndGetValue(queryCompanyAr); Assert.IsTrue(company.VipCustomer != null); this.EnqueueTestComplete(); }