From 5739b944531f30b9379a2df5bff5eb8773c7027f Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 22 Jan 2020 14:58:42 +0100 Subject: [PATCH 1/3] Moved tests for `NoEntityFrameworkTests` into a different database, because two variants of `TodoItem` exist (where one is a subset of the other), causing tests to fail/succeed depending on their execution order. A separate database is needed instead of schema, because `context.Database.EnsureCreated()` only checks for database existence and does not create additional tables when the database already exists. Furthermore, I decided to remove fields from `NoEntityFrameworkExample.Models.TodoItem` that do not exist in the INSERT SQL statement in `NoEntityFrameworkExample.Services.TodoItemService` and because non-nullable CreatedDate causes insert to fail. --- .../NoEntityFrameworkExample/Models/TodoItem.cs | 12 ------------ .../NoEntityFrameworkExample/appsettings.json | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs b/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs index d380b0d018..7836ecdd58 100644 --- a/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs +++ b/src/Examples/NoEntityFrameworkExample/Models/TodoItem.cs @@ -20,17 +20,5 @@ public TodoItem() [Attr] public Guid GuidProperty { get; set; } - - [Attr] - public DateTime CreatedDate { get; set; } - - [Attr(isFilterable: false, isSortable: false)] - public DateTime? AchievedDate { get; set; } - - [Attr] - public DateTime? UpdatedDate { get; set; } - - [Attr] - public DateTimeOffset? OffsetDate { get; set; } } } diff --git a/src/Examples/NoEntityFrameworkExample/appsettings.json b/src/Examples/NoEntityFrameworkExample/appsettings.json index ed7d5999d7..7392e6fb01 100644 --- a/src/Examples/NoEntityFrameworkExample/appsettings.json +++ b/src/Examples/NoEntityFrameworkExample/appsettings.json @@ -1,6 +1,6 @@ -{ +{ "Data": { - "DefaultConnection": "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=postgres" + "DefaultConnection": "Host=localhost;Port=5432;Database=JsonApiDotNetCoreNoEFCoreExample;User ID=postgres;Password=postgres" }, "Logging": { "IncludeScopes": false, From d267ae15016ae183c4644533cfe3f7deb65c9dfd Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 5 Feb 2020 13:04:09 +0100 Subject: [PATCH 2/3] Fixed another bug, where tests would sometimes fail This occured when working in the solution for a while, building and rebuilding one or more projects individually. What happened is that the appsettings.json from NoEntityFrameworkCoreExample project would overwrite the one from JsonApiDotNetCoreExample in the output folder of JsonApiDotNetCoreExample. Causing that project to reference the wrong database. I solved this by removing the unneeded dependency between these projects and by relying on automatic copying of appsettings by the project system. I removed the copied appsettings.json files from the test projects, which end up in the output directory anyway (because they reference the *Example projects). --- .../JsonApiDotNetCoreExampleTests.csproj | 3 +-- .../appsettings.json | 15 --------------- .../NoEntityFrameworkTests.csproj | 4 ++-- test/NoEntityFrameworkTests/appsettings.json | 15 --------------- 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 test/JsonApiDotNetCoreExampleTests/appsettings.json delete mode 100644 test/NoEntityFrameworkTests/appsettings.json diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index d68923e892..b95b3dced5 100644 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -5,14 +5,13 @@ - + PreserveNewest - diff --git a/test/JsonApiDotNetCoreExampleTests/appsettings.json b/test/JsonApiDotNetCoreExampleTests/appsettings.json deleted file mode 100644 index 84f8cf4220..0000000000 --- a/test/JsonApiDotNetCoreExampleTests/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Data": { - "DefaultConnection": - "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=postgres" - }, - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Warning", - "System": "Warning", - "Microsoft": "Warning", - "JsonApiDotNetCore.Middleware.JsonApiExceptionFilter": "Critical" - } - } -} diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index a53c1e90ce..12c372c22d 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,4 +1,4 @@ - + $(NetCoreAppVersion) true @@ -9,7 +9,7 @@ true - + PreserveNewest diff --git a/test/NoEntityFrameworkTests/appsettings.json b/test/NoEntityFrameworkTests/appsettings.json deleted file mode 100644 index 84f8cf4220..0000000000 --- a/test/NoEntityFrameworkTests/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Data": { - "DefaultConnection": - "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=postgres" - }, - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Warning", - "System": "Warning", - "Microsoft": "Warning", - "JsonApiDotNetCore.Middleware.JsonApiExceptionFilter": "Critical" - } - } -} From 01b388fe5a9a168765a125c8bbe817da21569659 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 5 Feb 2020 13:05:04 +0100 Subject: [PATCH 3/3] Fixed invalid logging configuration --- src/Examples/JsonApiDotNetCoreExample/appsettings.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Examples/JsonApiDotNetCoreExample/appsettings.json b/src/Examples/JsonApiDotNetCoreExample/appsettings.json index 38f0280d9f..ef76af7eee 100644 --- a/src/Examples/JsonApiDotNetCoreExample/appsettings.json +++ b/src/Examples/JsonApiDotNetCoreExample/appsettings.json @@ -8,9 +8,7 @@ "Default": "Warning", "System": "Warning", "Microsoft": "Warning", - "LogLevel": { - "Microsoft.EntityFrameworkCore": "Debug" - } + "Microsoft.EntityFrameworkCore": "Debug" } } }