Exemple #1
0
        public async Task TestMethod1()
        {
            var provider = new ApiTestProvider <OWinStartup>("");
            {
                var req      = provider.GetRequest("/odata/Companies?$top=5&$expand=Addresses");
                var response = await req.GetAsync();

                Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK, await response.Content.ReadAsStringAsync());
                var companies = await response.Content.ReadAsAsync <ODataResponse <Company> >();

                Assert.IsTrue(companies.value.Any(), "No data was returned");
            }
        }
Exemple #2
0
        public async Task ReferenceMustSucceed()
        {
            var guid           = "C26F0FE8-98BC-41F0-8957-78270AB2C545";
            var guidNewAddress = "EBCF57A5-DF14-4087-B2E6-2A1FD33550A7";
            var company        = new Company()
            {
                Addresses = new[] { new Address {
                                        Id = Guid.Parse(guidNewAddress), Street = "Station", StreetSuffix = "123", ZipCode = "asdfasdf"
                                    } }
            };
            var provider = new ApiTestProvider <OWinStartup>("");
            {
                var reqC = new ODataRequest()
                {
                    id = new Uri($"http://{provider.Client.BaseAddress.Authority}/Addresses({guidNewAddress})")
                };
                var req = provider.GetRequest($"/odata/Companies({guid})/Addresses/$ref");
                req.And((c) => c.Content = new ObjectContent <ODataRequest>(reqC, JsonODataSerializerSettings(), "application/json"));
                var response = await req.SendAsync("PUT");

                Assert.AreEqual(System.Net.HttpStatusCode.NoContent, response.StatusCode, await response.Content.ReadAsStringAsync());
            }
        }