public async Task GetSingleProduct() { var response = SetUpResourceMock("SingleProduct.xml"); var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync<IEdmModel>()); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties, result.Count); }
public async Task GetSingleProductWithCategory() { var response = SetUpResourceMock("SingleProductWithCategory.xml"); var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync<IEdmModel>()); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties + 1, result.Count); Assert.Equal(categoryProperties, (result["Category"] as IDictionary<string, object>).Count); }
public async Task GetMultipleProducts() { var response = SetUpResourceMock("MultipleProducts.xml"); var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync<IEdmModel>()); var result = (await responseReader.GetResponseAsync(response)).Feed.Entries; Assert.Equal(20, result.Count()); Assert.Equal(productProperties, result.First().Data.Count); }
public async Task GetSingleCategoryWithProducts() { var response = SetUpResourceMock("SingleCategoryWithProducts.xml"); var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync<IEdmModel>()); var result = (await responseReader.GetResponseAsync(response)).AsEntry(false); Assert.Equal(categoryProperties + 1, result.Count); Assert.Equal(12, (result["Products"] as IEnumerable<IDictionary<string, object>>).Count()); Assert.Equal(productProperties, (result["Products"] as IEnumerable<IDictionary<string, object>>).First().Count); }
public async Task GetSingleProductWithCollectionOfPrimitiveProperties() { var response = SetUpResourceMock("SingleProductWithCollectionOfPrimitiveProperties.xml"); var responseReader = new ResponseReader(_session, null); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties + 2, result.Count); var tags = result["Tags"] as IList<dynamic>; Assert.Equal(2, tags.Count); Assert.Equal("Bakery", tags[0]); Assert.Equal("Food", tags[1]); var ids = result["Ids"] as IList<dynamic>; Assert.Equal(2, ids.Count); Assert.Equal(1, ids[0]); Assert.Equal(2, ids[1]); }
public async Task GetSingleProductWithComplexProperty() { var response = SetUpResourceMock("SingleProductWithComplexProperty.xml"); var responseReader = new ResponseReader(_session, null); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties + 1, result.Count); var quantity = result["Quantity"] as IDictionary<string, object>; Assert.NotNull(quantity); Assert.Equal(10d, quantity["Value"]); Assert.Equal("bags", quantity["Units"]); }
public async Task GetSingleProductWithEmptyCollectionOfComplexProperties() { var response = SetUpResourceMock("SingleProductWithEmptyCollectionOfComplexProperties.xml"); var responseReader = new ResponseReader(_session, null); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties + 1, result.Count); var tags = result["Tags"] as IList<dynamic>; Assert.Equal(0, tags.Count); }
public async Task GetSingleProductWithCollectionOfComplexProperties() { var response = SetUpResourceMock("SingleProductWithCollectionOfComplexProperties.xml"); var responseReader = new ResponseReader(_session, null); var result = (await responseReader.GetResponseAsync(response)).Entry; Assert.Equal(productProperties + 1, result.Count); var tags = result["Tags"] as IList<dynamic>; Assert.Equal(2, tags.Count); Assert.Equal("Food", tags[0]["group"]); Assert.Equal("Bakery", tags[0]["value"]); Assert.Equal("Food", tags[1]["group"]); Assert.Equal("Meat", tags[1]["value"]); }