-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes #1190: Enable case insensitive by default for query * upate the test cases * The Json string switches randomly, so change the codes to avoid random ordering. * Address the comment and rebase to main
- Loading branch information
Showing
9 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
93 changes: 93 additions & 0 deletions
93
test/Microsoft.AspNetCore.OData.E2E.Tests/ODataOrderByTest/OrderByMoreTest.cs
This file contains 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,93 @@ | ||
//----------------------------------------------------------------------------- | ||
// <copyright file="ODataOrderByMoreTest.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 System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.OData.E2E.Tests.Extensions; | ||
using Microsoft.AspNetCore.OData.Query; | ||
using Microsoft.AspNetCore.OData.TestCommon; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Newtonsoft.Json.Linq; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNetCore.OData.E2E.Tests.ODataOrderByTest | ||
{ | ||
public class ODataOrderByMoreTest : WebApiTestBase<ODataOrderByMoreTest> | ||
{ | ||
public ODataOrderByMoreTest(WebApiTestFixture<ODataOrderByMoreTest> fixture) | ||
:base(fixture) | ||
{ | ||
} | ||
|
||
protected static void UpdateConfigureServices(IServiceCollection services) | ||
{ | ||
services.ConfigureControllers(typeof(BooksController)); | ||
services.AddControllers() | ||
.AddOData(); // without any configuration | ||
} | ||
|
||
[Theory] | ||
[InlineData("/books?orderby=ISBN&top=1")] | ||
[InlineData("/books?orderby=isbn&top=1")] | ||
[InlineData("/books?$orderby=ISBN&top=1")] | ||
[InlineData("/books?$orderby=isbn&top=1")] | ||
public async Task TestOrderBy_WithDifferentPropertyCase(string requestUri) | ||
{ | ||
// Arrange | ||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri); | ||
HttpClient client = CreateClient(); | ||
|
||
// Act | ||
HttpResponseMessage response = await client.SendAsync(request); | ||
|
||
// Assert | ||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
var resultArray = await response.Content.ReadAsObject<JArray>(); | ||
|
||
JObject objectItem = Assert.IsType<JObject>(Assert.Single(resultArray)); | ||
Assert.Equal(2, objectItem.Properties().Count()); | ||
Assert.Equal("063-6-920-02371-5", objectItem["isbn"]); | ||
Assert.Equal(2, objectItem["id"]); | ||
} | ||
} | ||
|
||
[ApiController] | ||
[Route("[controller]")] | ||
public class BooksController : ControllerBase | ||
{ | ||
private static IList<Book> _books = new List<Book> | ||
{ | ||
new Book | ||
{ | ||
Id = 1, | ||
ISBN = "978-0-321-87758-1" | ||
}, | ||
new Book | ||
{ | ||
Id = 2, | ||
ISBN = "063-6-920-02371-5", | ||
} | ||
}; | ||
|
||
[HttpGet] | ||
public IEnumerable<Book> Get(ODataQueryOptions<Book> queryOptions) | ||
{ | ||
var queryable = (IQueryable<Book>)queryOptions.ApplyTo(_books.AsQueryable()); | ||
return queryable.ToList(); | ||
} | ||
} | ||
|
||
public class Book | ||
{ | ||
public int Id { get; set; } | ||
public string ISBN { get; set; } | ||
} | ||
} |
1c029ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not being merged into 8.2? The last 8.2 is broken.