From c170bc5ac084c20109dd68aa0f0db06ab01eda40 Mon Sep 17 00:00:00 2001 From: June Ngei Date: Fri, 13 May 2022 12:33:19 +0300 Subject: [PATCH 01/18] Fixed Select Wilcard on Action and Function --- .../Routing/ODataPathExtensions.cs | 2 +- .../Query/ODataQueryContextTests.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.OData/Routing/ODataPathExtensions.cs b/src/Microsoft.AspNetCore.OData/Routing/ODataPathExtensions.cs index a793641af..04a871050 100644 --- a/src/Microsoft.AspNetCore.OData/Routing/ODataPathExtensions.cs +++ b/src/Microsoft.AspNetCore.OData/Routing/ODataPathExtensions.cs @@ -158,7 +158,7 @@ internal static (IEdmProperty, IEdmStructuredType, string) GetPropertyAndStructu { if (structuredType == null) { - structuredType = operationSegment.EdmType as IEdmStructuredType; + structuredType = operationSegment.EdmType.AsElementType() as IEdmStructuredType; } string name = operationSegment.Operations.First().FullName() + typeCast; diff --git a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs index 67656bee5..ad72ac1e2 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs @@ -6,6 +6,8 @@ //------------------------------------------------------------------------------ using System; +using System.Collections; +using System.Collections.Generic; using Microsoft.AspNetCore.OData.Query; using Microsoft.AspNetCore.OData.Tests.Commons; using Microsoft.AspNetCore.OData.Tests.Models; @@ -90,6 +92,38 @@ public void CtorODataQueryContext_TakingClrTypeAndPath_SetsProperties() Assert.Same(entitySet, context.NavigationSource); Assert.Same(typeof(Customer), context.ElementClrType); } + [Fact] + public void CtorODataQueryContext_TakingOperationAndPath_SetsProperties() + { + // Arrange + ODataModelBuilder odataModel = new ODataModelBuilder().Add_Customer_EntityType(); + string setName = typeof(Customer).Name; + odataModel.EntitySet(setName); + odataModel.EntitySet("Customers").EntityType + .Collection.Function("GetAllCustomer") + .ReturnsCollectionFromEntitySet("GetAllCustomer"); + IEdmModel model = odataModel.GetEdmModel(); + IEnumerable operationConfiguration = odataModel.Operations; + + string qualifiedName = null; + foreach(var op in operationConfiguration) + { + qualifiedName = op.FullyQualifiedName; + } + IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet(setName); + IEdmEntityType entityType = entitySet.EntityType(); + IEnumerable operations = model.FindDeclaredOperations(qualifiedName); + + ODataPath path = new ODataPath(new EntitySetSegment(entitySet), new OperationSegment(operations,entitySet)); + + // Act + ODataQueryContext context = new ODataQueryContext(model, typeof(Customer), path); + + // Assert + Assert.Same(model, context.Model); + Assert.Same(entityType, context.TargetStructuredType); + Assert.Same(typeof(Customer), context.ElementClrType); + } [Fact] public void CtorODataQueryContext_TakingEdmType_ThrowsArgumentNull_Model() From c283b6cfed0255a0137099806347f18b84e44d0e Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 16 May 2022 10:40:50 +0300 Subject: [PATCH 02/18] Added spacing between tests Co-authored-by: John Gathogo --- .../Query/ODataQueryContextTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs index ad72ac1e2..015e53592 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs @@ -92,6 +92,7 @@ public void CtorODataQueryContext_TakingClrTypeAndPath_SetsProperties() Assert.Same(entitySet, context.NavigationSource); Assert.Same(typeof(Customer), context.ElementClrType); } + [Fact] public void CtorODataQueryContext_TakingOperationAndPath_SetsProperties() { From e06ddbbf566df6335961d8afa5e57410eed3e8c2 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 16 May 2022 10:41:54 +0300 Subject: [PATCH 03/18] Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs Co-authored-by: John Gathogo --- .../Query/ODataQueryContextTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs index 015e53592..bc05d1378 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs @@ -111,6 +111,7 @@ public void CtorODataQueryContext_TakingOperationAndPath_SetsProperties() { qualifiedName = op.FullyQualifiedName; } + IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet(setName); IEdmEntityType entityType = entitySet.EntityType(); IEnumerable operations = model.FindDeclaredOperations(qualifiedName); From b5cb5c2ea30651378652acddaf4abe097f03a3f2 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 16 May 2022 10:42:35 +0300 Subject: [PATCH 04/18] Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs Co-authored-by: John Gathogo --- .../Query/ODataQueryContextTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs index bc05d1378..02204e34d 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs @@ -116,7 +116,7 @@ public void CtorODataQueryContext_TakingOperationAndPath_SetsProperties() IEdmEntityType entityType = entitySet.EntityType(); IEnumerable operations = model.FindDeclaredOperations(qualifiedName); - ODataPath path = new ODataPath(new EntitySetSegment(entitySet), new OperationSegment(operations,entitySet)); + ODataPath path = new ODataPath(new EntitySetSegment(entitySet), new OperationSegment(operations, entitySet)); // Act ODataQueryContext context = new ODataQueryContext(model, typeof(Customer), path); From e858741e5c343ab958e1d5e79ea8ff2ae49be41b Mon Sep 17 00:00:00 2001 From: June Ngei Date: Tue, 17 May 2022 16:22:21 +0300 Subject: [PATCH 05/18] Added e2e test on select * on Function --- .../SelectWildCardOnFunctionTests.cs | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs new file mode 100644 index 000000000..79def1027 --- /dev/null +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -0,0 +1,116 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; +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 class SelectWildCardOnFunctionTests : WebODataTestBase + { + + + public class Startup : TestStartupBase + { + public override void ConfigureServices(IServiceCollection services) + { + services.ConfigureControllers(typeof(CustomersController)); + + IEdmModel model = SelectWildCardOnFunctionEdmModel.GetEdmModel(); + services.AddControllers().AddOData(opt => + { + opt.Select(); + opt.RouteOptions.EnableNonParenthesisForEmptyParameterFunction = true; + opt.AddRouteComponents("odata", model); + }); + } + } + public SelectWildCardOnFunctionTests(WebODataTestFixture fixture) + : base(fixture) + { + } + + /// + /// For Select query with wildcard on Function + /// + /// + [Fact] + public async Task SelectWildCardOnFunction_success() + { + //Arrange + string queryUrl = "odata/Customers/GetAllCustomer?$select=*"; + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl); + request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); + + //Act + HttpResponseMessage response = await this.Client.SendAsync(request); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + + List customers = JToken.Parse(await response.Content.ReadAsStringAsync())["value"].ToObject>(); + foreach(Customer c in customers) + { + Assert.NotNull(c.Id); + Assert.NotNull(c.Name); + Assert.NotNull(c.Status); + } + } + } + + + public class SelectWildCardOnFunctionEdmModel + { + public static IEdmModel GetEdmModel() + { + ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); + builder.EntitySet("Customers"); + builder.EntitySet("Customers").EntityType + .Collection.Function("GetAllCustomer") + .ReturnsCollectionFromEntitySet("GetAllCustomer"); + + return builder.GetEdmModel(); + } + } + + + public class Customer + { + public string Id { get; set; } + public string Name { get; set; } + public string Status { get; set; } + } + + + public class CustomersController : ControllerBase + { + [HttpGet] + public IEnumerable GetAllCustomer() + { + return new List() + { + new Customer + { + Id = "custId1", + Name = "John", + Status = "Active" + }, + new Customer + { + Id = "custId2", + Name = "John", + Status = "Active" + } + }; + } + } +} From 8ff989694c6cfdee8e91ff94a1a9826b0a426e5d Mon Sep 17 00:00:00 2001 From: Nthemba Date: Thu, 19 May 2022 11:03:16 +0300 Subject: [PATCH 06/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: John Gathogo --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 79def1027..34a9b6bb1 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -44,7 +44,7 @@ public SelectWildCardOnFunctionTests(WebODataTestFixture fixture) /// /// [Fact] - public async Task SelectWildCardOnFunction_success() + public async Task SelectWildCardOnFunction_Success() { //Arrange string queryUrl = "odata/Customers/GetAllCustomer?$select=*"; From 04003eddc206a7095a86c348916613b54280dba5 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Thu, 19 May 2022 11:03:27 +0300 Subject: [PATCH 07/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: John Gathogo --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 34a9b6bb1..84d96cd38 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -17,8 +17,6 @@ namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.SelectWilCardOnFunction public class SelectWildCardOnFunctionTests : WebODataTestBase { - - public class Startup : TestStartupBase { public override void ConfigureServices(IServiceCollection services) From 88dd812a3f14cbf484aec15c8ab088170aad46ac Mon Sep 17 00:00:00 2001 From: Nthemba Date: Thu, 19 May 2022 11:20:31 +0300 Subject: [PATCH 08/18] Apply suggestions from code review Co-authored-by: John Gathogo --- .../SelectWildCardOnFunctionTests.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 84d96cd38..0a8471fb0 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -14,7 +14,6 @@ namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.SelectWilCardOnFunction { - public class SelectWildCardOnFunctionTests : WebODataTestBase { public class Startup : TestStartupBase @@ -32,6 +31,7 @@ public override void ConfigureServices(IServiceCollection services) }); } } + public SelectWildCardOnFunctionTests(WebODataTestFixture fixture) : base(fixture) { @@ -65,7 +65,6 @@ public async Task SelectWildCardOnFunction_Success() } } - public class SelectWildCardOnFunctionEdmModel { public static IEdmModel GetEdmModel() @@ -80,7 +79,6 @@ public static IEdmModel GetEdmModel() } } - public class Customer { public string Id { get; set; } @@ -88,8 +86,7 @@ public class Customer public string Status { get; set; } } - - public class CustomersController : ControllerBase + public class CustomersController : ODataController { [HttpGet] public IEnumerable GetAllCustomer() From e88c26c6879d2eed1c19be6c952627fbb8284fe3 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Thu, 19 May 2022 11:21:25 +0300 Subject: [PATCH 09/18] Apply suggestions from code review Co-authored-by: John Gathogo --- .../SelectWildCardOnFunctionTests.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 0a8471fb0..2a7915e4a 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -70,10 +70,9 @@ public class SelectWildCardOnFunctionEdmModel public static IEdmModel GetEdmModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); - builder.EntitySet("Customers"); builder.EntitySet("Customers").EntityType - .Collection.Function("GetAllCustomer") - .ReturnsCollectionFromEntitySet("GetAllCustomer"); + .Collection.Function("GetAllCustomers") + .ReturnsCollectionFromEntitySet("Customers"); return builder.GetEdmModel(); } @@ -89,7 +88,7 @@ public class Customer public class CustomersController : ODataController { [HttpGet] - public IEnumerable GetAllCustomer() + public IEnumerable GetAllCustomers() { return new List() { From d77a3f7e7ac61f2acc5020af29f6d24e8ccb59e7 Mon Sep 17 00:00:00 2001 From: June Ngei Date: Thu, 19 May 2022 12:07:59 +0300 Subject: [PATCH 10/18] Moved EDMModel to startup class --- .../SelectWildCardOnFunctionTests.cs | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 2a7915e4a..323fe03a3 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -1,5 +1,6 @@ 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; @@ -22,7 +23,7 @@ public override void ConfigureServices(IServiceCollection services) { services.ConfigureControllers(typeof(CustomersController)); - IEdmModel model = SelectWildCardOnFunctionEdmModel.GetEdmModel(); + IEdmModel model = GetEdmModel(); services.AddControllers().AddOData(opt => { opt.Select(); @@ -30,6 +31,15 @@ public override void ConfigureServices(IServiceCollection services) opt.AddRouteComponents("odata", model); }); } + public static IEdmModel GetEdmModel() + { + ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); + builder.EntitySet("Customers").EntityType + .Collection.Function("GetAllCustomers") + .ReturnsCollectionFromEntitySet("Customers"); + + return builder.GetEdmModel(); + } } public SelectWildCardOnFunctionTests(WebODataTestFixture fixture) @@ -45,7 +55,7 @@ public SelectWildCardOnFunctionTests(WebODataTestFixture fixture) public async Task SelectWildCardOnFunction_Success() { //Arrange - string queryUrl = "odata/Customers/GetAllCustomer?$select=*"; + string queryUrl = "odata/Customers/GetAllCustomers?$select=*"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); @@ -59,25 +69,15 @@ public async Task SelectWildCardOnFunction_Success() foreach(Customer c in customers) { Assert.NotNull(c.Id); + Assert.Equal("custId1", c.Id); Assert.NotNull(c.Name); + Assert.Equal("John", c.Name); Assert.NotNull(c.Status); + Assert.Equal("Active", c.Status); } } } - public class SelectWildCardOnFunctionEdmModel - { - public static IEdmModel GetEdmModel() - { - ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); - builder.EntitySet("Customers").EntityType - .Collection.Function("GetAllCustomers") - .ReturnsCollectionFromEntitySet("Customers"); - - return builder.GetEdmModel(); - } - } - public class Customer { public string Id { get; set; } @@ -97,12 +97,6 @@ public IEnumerable GetAllCustomers() Id = "custId1", Name = "John", Status = "Active" - }, - new Customer - { - Id = "custId2", - Name = "John", - Status = "Active" } }; } From 2191c5acf503197e2078ef20c108d246588ade83 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 23 May 2022 12:40:22 +0300 Subject: [PATCH 11/18] Update test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs Co-authored-by: Kennedy Kang'ethe --- .../Query/ODataQueryContextTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs index 02204e34d..83a8c6c4d 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Query/ODataQueryContextTests.cs @@ -101,7 +101,7 @@ public void CtorODataQueryContext_TakingOperationAndPath_SetsProperties() string setName = typeof(Customer).Name; odataModel.EntitySet(setName); odataModel.EntitySet("Customers").EntityType - .Collection.Function("GetAllCustomer") + .Collection.Function("GetAllCustomers") .ReturnsCollectionFromEntitySet("GetAllCustomer"); IEdmModel model = odataModel.GetEdmModel(); IEnumerable operationConfiguration = odataModel.Operations; From 873d3e2144ba586422198302bab0f47b87c3e865 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 23 May 2022 12:40:37 +0300 Subject: [PATCH 12/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: John Gathogo --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 323fe03a3..cdc5225bb 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -31,6 +31,7 @@ public override void ConfigureServices(IServiceCollection services) opt.AddRouteComponents("odata", model); }); } + public static IEdmModel GetEdmModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); From cfb3a8b1e3ff4a888ef660aac5713f3f2a17eb53 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Mon, 23 May 2022 12:41:18 +0300 Subject: [PATCH 13/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Removed redundant null assertions Co-authored-by: John Gathogo --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index cdc5225bb..ed84fe3b9 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -69,11 +69,8 @@ public async Task SelectWildCardOnFunction_Success() List customers = JToken.Parse(await response.Content.ReadAsStringAsync())["value"].ToObject>(); foreach(Customer c in customers) { - Assert.NotNull(c.Id); Assert.Equal("custId1", c.Id); - Assert.NotNull(c.Name); Assert.Equal("John", c.Name); - Assert.NotNull(c.Status); Assert.Equal("Active", c.Status); } } From 57cef21f6c3e2ffb042f3727ccdea8a6966e0644 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Wed, 8 Jun 2022 12:26:45 +0300 Subject: [PATCH 14/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: Garrett DeBruin --- .../SelectWildCardOnFunctionTests.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index ed84fe3b9..96f21bccf 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -1,4 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +//----------------------------------------------------------------------------- +// +// Copyright (c) .NET Foundation and Contributors. All rights reserved. +// See License.txt in the project root for license information. +// +//------------------------------------------------------------------------------ + +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OData.Query; using Microsoft.AspNetCore.OData.Routing.Controllers; using Microsoft.AspNetCore.OData.TestCommon; From f917a177c6ede44e8bf765c211cc6561974232a6 Mon Sep 17 00:00:00 2001 From: Nthemba Date: Wed, 8 Jun 2022 12:27:34 +0300 Subject: [PATCH 15/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: Garrett DeBruin --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 96f21bccf..903026a46 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.OData.E2E.Tests.Query.SelectWilCardOnFunction { - public class SelectWildCardOnFunctionTests : WebODataTestBase + public sealed class SelectWildCardOnFunctionTests : WebODataTestBase { public class Startup : TestStartupBase { From f190852b7931d9d05a101013d2808ac7118a244b Mon Sep 17 00:00:00 2001 From: Nthemba Date: Wed, 8 Jun 2022 12:28:32 +0300 Subject: [PATCH 16/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: Garrett DeBruin --- .../SelectWildCardOnFunctionTests.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 903026a46..0f7bbcc67 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -64,21 +64,24 @@ public async Task SelectWildCardOnFunction_Success() { //Arrange string queryUrl = "odata/Customers/GetAllCustomers?$select=*"; - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl); - request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); - - //Act - HttpResponseMessage response = await this.Client.SendAsync(request); + using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl)) + { + request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); - // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + //Act + using (HttpResponseMessage response = await this.Client.SendAsync(request)) + { + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); - List customers = JToken.Parse(await response.Content.ReadAsStringAsync())["value"].ToObject>(); - foreach(Customer c in customers) - { - Assert.Equal("custId1", c.Id); - Assert.Equal("John", c.Name); - Assert.Equal("Active", c.Status); + List customers = JToken.Parse(await response.Content.ReadAsStringAsync())["value"].ToObject>(); + foreach(Customer c in customers) + { + Assert.Equal("custId1", c.Id); + Assert.Equal("John", c.Name); + Assert.Equal("Active", c.Status); + } + } } } } From 47e24b7b071bb0b203f88b5a1f5bf220d75fa09a Mon Sep 17 00:00:00 2001 From: Nthemba Date: Wed, 8 Jun 2022 14:33:05 +0300 Subject: [PATCH 17/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: Kennedy Kang'ethe --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index 0f7bbcc67..b5c03c2d7 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -64,6 +64,7 @@ public async Task SelectWildCardOnFunction_Success() { //Arrange string queryUrl = "odata/Customers/GetAllCustomers?$select=*"; + using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, queryUrl)) { request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json;odata.metadata=none")); From 6a00f100561f02d75152e60b35c5daf542a19ffe Mon Sep 17 00:00:00 2001 From: Nthemba Date: Wed, 8 Jun 2022 14:33:13 +0300 Subject: [PATCH 18/18] Update test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs Co-authored-by: Kennedy Kang'ethe --- .../SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs index b5c03c2d7..be96323ca 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Query/SelectWilCardOnFunction/SelectWildCardOnFunctionTests.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// +// // Copyright (c) .NET Foundation and Contributors. All rights reserved. // See License.txt in the project root for license information. //