Exemplo n.º 1
0
        public async Task GetExpandedLinkAnnotationDataAndLink()
        {
            var response       = SetUpResourceMock("AccountTasksAndLink.json");
            var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>());
            var result         = (await responseReader.GetResponseAsync(response)).Feed;

            Assert.NotNull(result.Entries.First().LinkAnnotations);
        }
Exemplo n.º 2
0
        public async Task GetSingleProduct()
        {
            var response       = SetUpResourceMock("SingleProduct.xml");
            var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>());
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            Assert.Equal(productProperties, result.Count);
        }
Exemplo n.º 3
0
        public async Task ExampleActionReturnsComplexType()
        {
            var response       = SetUpResourceMock("ExampleActionComplexType.json");
            var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>());
            var result         = (await responseReader.GetResponseAsync(response)).Feed;

            Assert.NotNull(result.Entries.First());
        }
Exemplo n.º 4
0
        public async Task GetSingleProductWithCategory()
        {
            var response       = SetUpResourceMock("SingleProductWithCategory.xml");
            var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>());
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            Assert.Equal(productProperties + 1, result.Count);
            Assert.Equal(categoryProperties, (result["Category"] as IDictionary <string, object>).Count);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public async Task GetMultipleProductsWithCategory()
        {
            var response       = SetUpResourceMock("MultipleProductsWithCategory.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 + 1, result.First().Data.Count);
            Assert.Equal(categoryProperties, (result.First().Data["Category"] as IDictionary <string, object>).Count);
        }
        public async Task ExampleActionReturnsComplexType()
        {
            var response       = SetUpResourceMock("ExampleActionComplexType.json");
            var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>());
            var result         = (await responseReader.GetResponseAsync(response)).Feed;
            var entry          = result.Entries.First();

            Assert.NotNull(entry);
            Assert.Equal("MyPropertyValue", entry.Data["SomeProperty"]);
        }
    public async Task GetSingleCategoryWithProducts()
    {
        var response       = SetUpResourceMock("SingleCategoryWithProducts.xml");
        var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync <IEdmModel>().ConfigureAwait(false));
        var result         = (await responseReader.GetResponseAsync(response).ConfigureAwait(false)).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);
    }
Exemplo n.º 9
0
        public async Task GetSingleProductWithEmptyCollectionOfComplexProperties()
        {
            var response       = SetUpResourceMock("SingleProductWithEmptyCollectionOfComplexProperties.xml");
            var responseReader = new ResponseReader(_session, null);
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            Assert.Equal(productProperties + 1, result.Count);
            var tags = result["Tags"] as IList <dynamic>;

            Assert.Equal(0, tags.Count);
        }
Exemplo n.º 10
0
        public async Task GetSingleProductWithComplexProperty()
        {
            var response       = SetUpResourceMock("SingleProductWithComplexProperty.xml");
            var responseReader = new ResponseReader(_session, null);
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            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"]);
        }
Exemplo n.º 11
0
        public async Task GetSingleProductWithCollectionOfComplexProperties()
        {
            var response       = SetUpResourceMock("SingleProductWithCollectionOfComplexProperties.xml");
            var responseReader = new ResponseReader(_session, null);
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            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"]);
        }
Exemplo n.º 12
0
    public async Task ReadUntypedAsStrings()
    {
        _session.Settings.ReadUntypedAsString = false;
        var response = SetUpResourceMock("OpenTypeV401.json");
        var edmModel = await _client.GetMetadataAsync <IEdmModel>().ConfigureAwait(false);

        var responseReader = new ResponseReader(_session, edmModel);
        var result         = (await responseReader.GetResponseAsync(response).ConfigureAwait(false)).Feed;
        var entry          = result.Entries.First();

        Assert.NotNull(entry);
        Assert.Equal(42m, entry.Data["Id"]);
        Assert.Equal(43m, entry.Data["IntegerProperty"]);
        Assert.Null(entry.Data["NullProperty"]);
        Assert.Equal("some string", entry.Data["StringProperty"]);
    }
Exemplo n.º 13
0
        public async Task GetSingleProductWithCollectionOfPrimitiveProperties()
        {
            var response       = SetUpResourceMock("SingleProductWithCollectionOfPrimitiveProperties.xml");
            var responseReader = new ResponseReader(_session, null);
            var result         = (await responseReader.GetResponseAsync(response)).AsEntry(false);

            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]);
        }