Exemplo n.º 1
0
        public async Task UnboundFunctionInFilter()
        {
            // Arrange
            const int          CustomerId     = 407;
            ConventionCustomer expectCustomer = new ConventionCustomersController().GetConventionCustomerById(CustomerId); // expect customer instance

            Assert.NotNull(expectCustomer);

            var        requestUri = "odata/ConventionCustomers?$filter=Microsoft.AspNetCore.OData.E2E.Tests.UnboundOperation.GetConventionCustomerNameById(CustomerId%3D" + CustomerId + ") eq 'Name 7'";
            HttpClient client     = CreateClient();

            // Act
            var response = await client.GetAsync(requestUri);

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Exemplo n.º 2
0
        public async Task FunctionImportFollowedByProperty()
        {
            // Arrange
            const int          CustomerId     = 407;
            ConventionCustomer expectCustomer = new ConventionCustomersController().GetConventionCustomerById(CustomerId); // expect customer instance

            Assert.NotNull(expectCustomer);

            // Act
            var        requestUri = "odata/GetConventionCustomerByIdImport(CustomerId=" + CustomerId + ")/Name";
            HttpClient client     = CreateClient();
            var        response   = await client.GetAsync(requestUri);

            var responseString = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.True(response.IsSuccessStatusCode);
            string expect = "\"value\":\"" + expectCustomer.Name + "\"";

            Assert.Contains(expect, responseString);
        }
Exemplo n.º 3
0
        public async Task FunctionImportWithOneParameters()
        {
            // Arrange
            const int          CustomerId     = 407;
            ConventionCustomer expectCustomer = new ConventionCustomersController().GetConventionCustomerById(CustomerId);

            // Act
            var        requestUri = "odata/GetConventionCustomerByIdImport(CustomerId=" + CustomerId + ")";
            HttpClient client     = CreateClient();
            var        response   = await client.GetAsync(requestUri);

            var responseString = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.NotNull(expectCustomer);
            Assert.True(response.IsSuccessStatusCode);
            Assert.Contains("/$metadata#ConventionCustomers/$entity", responseString);
            string expect = "\"ID\":" + expectCustomer.ID;

            Assert.Contains(expect, responseString);
            expect = "\"Name\":\"" + expectCustomer.Name + "\"";
            Assert.Contains(expect, responseString);
        }