Example #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 = this.BaseAddress + "/odata/ConventionCustomers?$filter=Microsoft.Test.E2E.AspNet.OData.UnBoundFunction.GetConventionCustomerNameById(CustomerId%3D" + CustomerId + ") eq 'Name 7'";

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

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Example #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 = this.BaseAddress + "/odata/GetConventionCustomerByIdImport(CustomerId=" + CustomerId + ")/Name";
            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);
        }
Example #3
0
        public async Task FunctionImportWithOneParameters()
        {
            // Arrange
            const int          CustomerId     = 407;
            ConventionCustomer expectCustomer = new ConventionCustomersController().GetConventionCustomerById(CustomerId);

            // Act
            var requestUri = this.BaseAddress + "/odata/GetConventionCustomerByIdImport(CustomerId=" + CustomerId + ")";
            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);
        }