public void When_Querying_For_NavigationProperty_Then_Return_Single_Expected_EntityType() { using (var scenario = new ODataScenario() .WithSuppliedProducts(Any.Suppliers()) .Start()) { var context = GetDataServiceContext(scenario.GetBaseAddress()); var dQuery = context.CreateQuery<SuppliedProduct>("/" + "SuppliedProducts"); IReadOnlyQueryableSet<SuppliedProduct> productSet = new ReadOnlyQueryableSet<SuppliedProduct>(dQuery, context); var products = productSet.Expand(p => p.Supplier).ExecuteAsync().Result; products.CurrentPage.Count.Should().Be(25); var suppliedProduct = products.CurrentPage.RandomElement() as SuppliedProduct; string supplierPath = suppliedProduct.GetPath("Supplier"); var supplierQuery = context.CreateQuery<Supplier>(supplierPath); IReadOnlyQueryableSet<Supplier> supplierSet = new ReadOnlyQueryableSet<Supplier>(supplierQuery, context); var supplier = supplierSet.ExecuteSingleAsync().Result; suppliedProduct.Supplier.Id.Should().Be(supplier.Id); } }
public void When_Querying_For_NavigationProperty_Then_Return_Single_Expected_EntityType() { using (var scenario = new ODataScenario() .WithSuppliedProducts(Any.Suppliers()) .Start()) { var context = GetDataServiceContext(scenario.GetBaseAddress()); var dQuery = context.CreateQuery <SuppliedProduct>("/" + "SuppliedProducts"); IReadOnlyQueryableSet <SuppliedProduct> productSet = new ReadOnlyQueryableSet <SuppliedProduct>(dQuery, context); var products = productSet.Expand(p => p.Supplier).ExecuteAsync().Result; products.CurrentPage.Count.Should().Be(25); var suppliedProduct = products.CurrentPage.RandomElement() as SuppliedProduct; string supplierPath = suppliedProduct.GetPath("Supplier"); var supplierQuery = context.CreateQuery <Supplier>(supplierPath); IReadOnlyQueryableSet <Supplier> supplierSet = new ReadOnlyQueryableSet <Supplier>(supplierQuery, context); var supplier = supplierSet.ExecuteSingleAsync().Result; suppliedProduct.Supplier.Id.Should().Be(supplier.Id); } }