Skip to content

Commit 1c5f00a

Browse files
committed
(#413) dotnet 10 (no efcore) support
1 parent 50bc510 commit 1c5f00a

File tree

14 files changed

+364
-162
lines changed

14 files changed

+364
-162
lines changed

tests/CommunityToolkit.Datasync.Client.Test/Query/IDatasyncPullQuery_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ public void Linq_Where_StartsWith_InvariantIgnoreCase()
11771177
);
11781178
}
11791179

1180-
[Fact]
1180+
[Fact(Skip = "OData v8.4 does not allow string.contains")]
11811181
public void Linq_Where_String_Contains()
11821182
{
11831183
string[] ratings = ["A", "B"];

tests/CommunityToolkit.Datasync.Client.Test/Query/IDatasyncQueryable_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ public void Linq_Where_StartsWith_InvariantIgnoreCase()
14161416
);
14171417
}
14181418

1419-
[Fact]
1419+
[Fact(Skip = "OData v8.4 does not allow string.contains")]
14201420
public void Linq_Where_String_Contains()
14211421
{
14221422
string[] ratings = ["A", "B"];

tests/CommunityToolkit.Datasync.Client.Test/Service/DatasyncServiceClient_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3547,7 +3547,7 @@ public void Linq_Where_StartsWith_InvariantIgnoreCase()
35473547
);
35483548
}
35493549

3550-
[Fact]
3550+
[Fact(Skip = "OData v8.4 does not allow string.contains")]
35513551
public void Linq_Where_String_Contains()
35523552
{
35533553
string[] ratings = ["A", "B"];

tests/CommunityToolkit.Datasync.Client.Test/Service/Integration_Query_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ await KitchenSinkQueryTest(
540540
// );
541541
//}
542542

543-
[Fact]
543+
[Fact(Skip = "OData v8.4 does not allow string.contains")]
544544
public async Task KitchenSinkQueryTest_020()
545545
{
546546
SeedKitchenSinkWithCountryData();

tests/CommunityToolkit.Datasync.Server.NSwag.Test/NSwag_Tests.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
using CommunityToolkit.Datasync.Server.NSwag.Test.Service;
88
using CommunityToolkit.Datasync.TestCommon;
9+
using Microsoft.AspNetCore.Hosting;
910
using Microsoft.AspNetCore.Mvc;
1011
using Microsoft.AspNetCore.TestHost;
12+
using Microsoft.Extensions.DependencyInjection;
13+
using Microsoft.Extensions.Hosting;
1114
using NSwag;
1215
using System.Reflection;
1316
using System.Text.RegularExpressions;
@@ -17,12 +20,26 @@ namespace CommunityToolkit.Datasync.Server.NSwag.Test;
1720
[ExcludeFromCodeCoverage]
1821
public class NSwag_Tests
1922
{
20-
private readonly TestServer server = NSwagServer.CreateTestServer();
21-
2223
[Fact]
2324
public async Task NSwag_GeneratesSwagger()
2425
{
25-
HttpClient client = this.server.CreateClient();
26+
using IHost host = new HostBuilder().ConfigureWebHost(builder =>
27+
{
28+
builder
29+
.UseTestServer()
30+
.UseEnvironment("Test")
31+
.UseContentRoot(AppContext.BaseDirectory)
32+
.UseStartup<ServiceStartup>();
33+
}).Build();
34+
await host.StartAsync();
35+
36+
TestServer server = host.GetTestServer();
37+
38+
using IServiceScope scope = server.Services.CreateScope();
39+
ServiceDbContext context = scope.ServiceProvider.GetRequiredService<ServiceDbContext>();
40+
context.InitializeDatabase();
41+
42+
HttpClient client = server.CreateClient();
2643
string actualContent = (await client.GetStringAsync("swagger/v1/swagger.json")).NormalizeContent();
2744
string expectedContent = Assembly.GetExecutingAssembly().ReadExternalFile("swagger.json");
2845

@@ -56,17 +73,16 @@ public void NSwag_AddMissingSchemaProperties_CornerCase()
5673
act.Should().NotThrow();
5774
}
5875

59-
[Fact]
60-
public void ContainsRequestHeader_ReturnsFalse_WhenQueryParam()
76+
[Theory]
77+
[InlineData("X-DOES-NOT-EXIST", false)]
78+
[InlineData("$count", false)]
79+
public void ContainsRequestHeader_ReturnsFalse_WhenQueryParam(string headerName, bool expected)
6180
{
6281
OpenApiOperation sut = new();
6382
sut.AddODataQueryParameters();
6483

65-
// Something that doesn't exist.
66-
sut.ContainsRequestHeader("X-DOES-NOT-EXIST").Should().BeFalse();
67-
68-
// Something that exists as a query parameter.
69-
sut.ContainsRequestHeader("$count").Should().BeFalse();
84+
// Check the requested parameters
85+
sut.ContainsRequestHeader(headerName).Should().Be(expected);
7086
}
7187

7288
[Theory]

tests/CommunityToolkit.Datasync.Server.NSwag.Test/Service/NSwagServer.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,13 @@
44

55
using Microsoft.AspNetCore.Builder;
66
using Microsoft.AspNetCore.Hosting;
7-
using Microsoft.AspNetCore.TestHost;
87
using Microsoft.Data.Sqlite;
98
using Microsoft.EntityFrameworkCore;
109
using Microsoft.Extensions.Configuration;
1110
using Microsoft.Extensions.DependencyInjection;
12-
using Microsoft.Extensions.Hosting;
1311

1412
namespace CommunityToolkit.Datasync.Server.NSwag.Test.Service;
1513

16-
[ExcludeFromCodeCoverage]
17-
internal static class NSwagServer
18-
{
19-
internal static TestServer CreateTestServer()
20-
{
21-
IHost host = new HostBuilder().ConfigureWebHost(builder =>
22-
{
23-
builder
24-
.UseTestServer()
25-
.UseEnvironment("Test")
26-
.UseContentRoot(AppContext.BaseDirectory)
27-
.UseStartup<ServiceStartup>();
28-
}).Build();
29-
TestServer server = host.GetTestServer();
30-
31-
using IServiceScope scope = server.Services.CreateScope();
32-
ServiceDbContext context = scope.ServiceProvider.GetRequiredService<ServiceDbContext>();
33-
context.InitializeDatabase();
34-
35-
return server;
36-
}
37-
}
38-
3914
[ExcludeFromCodeCoverage]
4015
internal class ServiceStartup
4116
{

tests/CommunityToolkit.Datasync.Server.NSwag.Test/swagger.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"tags": [
1616
"KitchenReader"
1717
],
18-
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n\n\n- $count is used to return a count of entities within the search parameters within the response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\n\n\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
18+
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n- $count is used to return a count of entities within the search parameters within the PagedResult response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
1919
"operationId": "KitchenReader_Query",
2020
"parameters": [
2121
{
@@ -295,7 +295,7 @@
295295
"tags": [
296296
"KitchenSink"
297297
],
298-
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n\n\n- $count is used to return a count of entities within the search parameters within the response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\n\n\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
298+
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n- $count is used to return a count of entities within the search parameters within the PagedResult response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
299299
"operationId": "KitchenSink_Query",
300300
"parameters": [
301301
{
@@ -750,7 +750,7 @@
750750
"tags": [
751751
"TodoItem"
752752
],
753-
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n\n\n- $count is used to return a count of entities within the search parameters within the response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\n\n\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
753+
"summary": "The GET method is used to retrieve resource representation. The resource is never modified.\nIn this case, an OData v4 query is accepted with the following options:\n- $count is used to return a count of entities within the search parameters within the PagedResult response.\n- $filter is used to restrict the entities to be sent.\n- $orderby is used for ordering the entities to be sent.\n- $select is used to select which properties of the entities are sent.\n- $skip is used to skip some entities\n- $top is used to limit the number of entities returned.\nIn addition, the __includeDeleted parameter is used to decide whether to include soft-deleted items in the result.",
754754
"operationId": "TodoItem_Query",
755755
"parameters": [
756756
{

tests/CommunityToolkit.Datasync.Server.OpenApi.Test/OpenApi_Tests.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
using CommunityToolkit.Datasync.Server.OpenApi.Test.Service;
66
using CommunityToolkit.Datasync.TestCommon;
7+
using Microsoft.AspNetCore.Hosting;
78
using Microsoft.AspNetCore.TestHost;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Hosting;
811
using System.Reflection;
912
using System.Text.RegularExpressions;
1013

@@ -13,12 +16,26 @@ namespace CommunityToolkit.Datasync.Server.OpenApi.Test;
1316
[ExcludeFromCodeCoverage]
1417
public class OpenApi_Tests
1518
{
16-
private readonly TestServer server = OpenApiServer.CreateTestServer();
17-
1819
[Fact]
1920
public async Task GeneratesCorrectOpenApiFile()
2021
{
21-
HttpClient client = this.server.CreateClient();
22+
using IHost host = new HostBuilder().ConfigureWebHost(builder =>
23+
{
24+
builder
25+
.UseTestServer()
26+
.UseEnvironment("Test")
27+
.UseContentRoot(AppContext.BaseDirectory)
28+
.UseStartup<ServiceStartup>();
29+
}).Build();
30+
await host.StartAsync();
31+
32+
TestServer server = host.GetTestServer();
33+
34+
using IServiceScope scope = server.Services.CreateScope();
35+
ServiceDbContext context = scope.ServiceProvider.GetRequiredService<ServiceDbContext>();
36+
context.InitializeDatabase();
37+
38+
HttpClient client = server.CreateClient();
2239
string actualContent = (await client.GetStringAsync("openapi/v1.json")).NormalizeContent();
2340
string expectedContent = Assembly.GetExecutingAssembly().ReadExternalFile("openapi.json");
2441

tests/CommunityToolkit.Datasync.Server.OpenApi.Test/Service/OpenApiServer.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,6 @@
1313

1414
namespace CommunityToolkit.Datasync.Server.OpenApi.Test.Service;
1515

16-
[ExcludeFromCodeCoverage]
17-
internal static class OpenApiServer
18-
{
19-
internal static TestServer CreateTestServer()
20-
{
21-
IHost host = new HostBuilder().ConfigureWebHost(builder =>
22-
{
23-
builder
24-
.UseTestServer()
25-
.UseEnvironment("Test")
26-
.UseContentRoot(AppContext.BaseDirectory)
27-
.UseStartup<ServiceStartup>();
28-
}).Build();
29-
TestServer server = host.GetTestServer();
30-
31-
using IServiceScope scope = server.Services.CreateScope();
32-
ServiceDbContext context = scope.ServiceProvider.GetRequiredService<ServiceDbContext>();
33-
context.InitializeDatabase();
34-
35-
return server;
36-
}
37-
}
38-
3916
[ExcludeFromCodeCoverage]
4017
internal class ServiceStartup
4118
{

0 commit comments

Comments
 (0)