Пример #1
0
        public async Task Get_OpenEntityTypeWithMultiplePropertySelect(string select)
        {
            // Arrange
            string requestUri = "http://localhost/odata/SimpleOpenCustomers?" + select;

            IEdmModel model  = GetEdmModel();
            var       server = TestServerUtils.Create(opt => opt.AddModel("odata", model).Select(), typeof(SimpleOpenCustomersController));
            var       client = server.CreateClient();

            // Act
            HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Get, requestUri);
            HttpResponseMessage response = await client.SendAsync(request);

            // Assert
            //  Assert.True(response.IsSuccessStatusCode);
            JObject result      = JObject.Parse(await response.Content.ReadAsStringAsync());
            var     resultArray = result["value"] as JArray;

            Assert.Equal(6, resultArray.Count);
            Assert.Equal(@"[
  {
    ""Address"": {
      ""Street"": ""Street 0"",
      ""City"": ""City 0""
    }
  },
  {
    ""Address"": {
      ""Street"": ""Street 1"",
      ""City"": ""City 1""
    }
  },
  {
    ""Address"": {
      ""Street"": ""Street 2"",
      ""City"": ""City 2""
    }
  },
  {
    ""Address"": {
      ""Street"": ""Street 3"",
      ""City"": ""City 3""
    }
  },
  {
    ""Address"": {
      ""Street"": ""Street 4"",
      ""City"": ""City 4""
    }
  },
  {
    ""@odata.type"": ""#Microsoft.AspNetCore.OData.Tests.Models.SimpleVipCustomer"",
    ""Address"": {
      ""Street"": ""Vip Street "",
      ""City"": ""Vip City ""
    }
  }
]", resultArray.ToString());
        }
Пример #2
0
        private HttpClient GetClient()
        {
            var controllers = new[] { typeof(OpenCustomersController) };

            var model  = GetEdmModel();
            var server = TestServerUtils.Create(opt => opt.AddModel("odata", model), typeof(OpenCustomersController));

            return(server.CreateClient());
        }
Пример #3
0
        public async Task Get_UnTyped_DollarCount(string requestUri, string expectedResult)
        {
            // Arrange
            IEdmModel model  = GetUntypedEdmModel();
            var       server = TestServerUtils.Create(opt => opt.AddModel("odata", model).Count(), typeof(UntypedSimpleOpenCustomersController));
            var       client = server.CreateClient();

            // Act
            HttpResponseMessage response = await client.GetAsync(_untypedCustomerRequestRooturl + requestUri);

            // Assert
            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal(expectedResult, await response.Content.ReadAsStringAsync());
        }
        private static HttpClient GetClient()
        {
            ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();

            modelBuilder.EntitySet <UnicodeCharUser>("UnicodeCharUsers");

            var controllers = new[] { typeof(UnicodeCharUsersController) };
            var server      = TestServerUtils.Create(opt =>
            {
                opt.Select().OrderBy().Filter().Expand().Count().SetMaxTop(null);
                opt.AddModel("odata", modelBuilder.GetEdmModel());
            },
                                                     controllers);

            return(server.CreateClient());
        }
Пример #5
0
        private HttpClient GetClient(IEdmModel model, params Type[] controllers)
        {
            var server = TestServerUtils.Create(opt => opt.AddModel("odata", model), controllers);

            return(server.CreateClient());
        }