-
Notifications
You must be signed in to change notification settings - Fork 186
Fixed Select Wilcard on Action and Function #594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c170bc5
Fixed Select Wilcard on Action and Function
c283b6c
Added spacing between tests
Nthemba e06ddbb
Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextT…
Nthemba b5cb5c2
Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextT…
Nthemba e858741
Added e2e test on select * on Function
8ff9896
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba 04003ed
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba 88dd812
Apply suggestions from code review
Nthemba e88c26c
Apply suggestions from code review
Nthemba d77a3f7
Moved EDMModel to startup class
2191c5a
Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextT…
Nthemba 873d3e2
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba cfb3a8b
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba 57cef21
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba f917a17
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba f190852
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba 47e24b7
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba 6a00f10
Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardO…
Nthemba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| //----------------------------------------------------------------------------- | ||
| // <copyright file="SelectWildCardOnFunctionTests.cs" company=".NET Foundation"> | ||
| // Copyright (c) .NET Foundation and Contributors. All rights reserved. | ||
| // See License.txt in the project root for license information. | ||
| // </copyright> | ||
| //------------------------------------------------------------------------------ | ||
|
|
||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.OData.Query; | ||
| using Microsoft.AspNetCore.OData.Routing.Controllers; | ||
| using Microsoft.AspNetCore.OData.TestCommon; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.OData.Edm; | ||
| using Microsoft.OData.ModelBuilder; | ||
| using Newtonsoft.Json.Linq; | ||
| using System.Collections.Generic; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Net.Http.Headers; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.SelectWilCardOnFunction | ||
| { | ||
| public sealed class SelectWildCardOnFunctionTests : WebODataTestBase<SelectWildCardOnFunctionTests.Startup> | ||
| { | ||
| public class Startup : TestStartupBase | ||
| { | ||
| public override void ConfigureServices(IServiceCollection services) | ||
| { | ||
| services.ConfigureControllers(typeof(CustomersController)); | ||
|
|
||
| IEdmModel model = GetEdmModel(); | ||
| services.AddControllers().AddOData(opt => | ||
| { | ||
| opt.Select(); | ||
| opt.RouteOptions.EnableNonParenthesisForEmptyParameterFunction = true; | ||
| opt.AddRouteComponents("odata", model); | ||
| }); | ||
| } | ||
|
|
||
| public static IEdmModel GetEdmModel() | ||
| { | ||
| ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); | ||
| builder.EntitySet<Customer>("Customers").EntityType | ||
| .Collection.Function("GetAllCustomers") | ||
| .ReturnsCollectionFromEntitySet<Customer>("Customers"); | ||
|
|
||
| return builder.GetEdmModel(); | ||
| } | ||
| } | ||
|
|
||
| public SelectWildCardOnFunctionTests(WebODataTestFixture<Startup> fixture) | ||
| : base(fixture) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// For Select query with wildcard on Function | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| [Fact] | ||
| public async Task SelectWildCardOnFunction_Success() | ||
| { | ||
| //Arrange | ||
| string queryUrl = "odata/Customers/GetAllCustomers?$select=*"; | ||
|
Nthemba marked this conversation as resolved.
|
||
|
|
||
| using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl)) | ||
| { | ||
| request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); | ||
|
|
||
| //Act | ||
| using (HttpResponseMessage response = await this.Client.SendAsync(request)) | ||
| { | ||
| // Assert | ||
| Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
|
|
||
| List<Customer> customers = JToken.Parse(await response.Content.ReadAsStringAsync())["value"].ToObject<List<Customer>>(); | ||
| foreach(Customer c in customers) | ||
| { | ||
| Assert.Equal("custId1", c.Id); | ||
| Assert.Equal("John", c.Name); | ||
| Assert.Equal("Active", c.Status); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class Customer | ||
| { | ||
| public string Id { get; set; } | ||
| public string Name { get; set; } | ||
| public string Status { get; set; } | ||
| } | ||
|
|
||
| public class CustomersController : ODataController | ||
| { | ||
| [HttpGet] | ||
| public IEnumerable<Customer> GetAllCustomers() | ||
| { | ||
| return new List<Customer>() | ||
| { | ||
| new Customer | ||
| { | ||
| Id = "custId1", | ||
| Name = "John", | ||
| Status = "Active" | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.