From 88e29848a8120053bb3ae7c049d3de57b67f3b09 Mon Sep 17 00:00:00 2001 From: Yohan Mishkin Date: Fri, 25 Aug 2017 22:30:33 -0400 Subject: [PATCH 1/7] Upgrade to .net core 2.0 --- JsonApiDotnetCore.sln | 45 ++++++++++--------- .../JsonApiDotNetCoreExample.csproj | 28 ++++++------ .../NoEntityFrameworkExample.csproj | 14 +++--- .../ReportsExample/ReportsExample.csproj | 1 - .../Internal/JsonApiRouteHandler.cs | 6 +-- .../JsonApiDotNetCore.csproj | 15 +++---- .../JsonApiDotNetCoreExampleTests.csproj | 14 +++--- .../NoEntityFrameworkTests.csproj | 17 +++---- test/UnitTests/UnitTests.csproj | 6 +-- 9 files changed, 68 insertions(+), 78 deletions(-) diff --git a/JsonApiDotnetCore.sln b/JsonApiDotnetCore.sln index b4ff89b0aa..a144223671 100644 --- a/JsonApiDotnetCore.sln +++ b/JsonApiDotnetCore.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.9 +VisualStudioVersion = 15.0.26730.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore", "src\JsonApiDotNetCore\JsonApiDotNetCore.csproj", "{C0EC9E70-EB2E-436F-9D94-FA16FA774123}" EndProject @@ -18,15 +18,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkExample", "src\Examples\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{570165EC-62B5-4684-A139-8D2A30DD4475}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoEntityFrameworkExample", "src\Examples\NoEntityFrameworkExample\NoEntityFrameworkExample.csproj", "{570165EC-62B5-4684-A139-8D2A30DD4475}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoEntityFrameworkTests", "test\NoEntityFrameworkTests\NoEntityFrameworkTests.csproj", "{73DA578D-A63F-4956-83ED-6D7102E09140}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoEntityFrameworkTests", "test\NoEntityFrameworkTests\NoEntityFrameworkTests.csproj", "{73DA578D-A63F-4956-83ED-6D7102E09140}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{6D4BD85A-A262-44C6-8572-FE3A30410BF3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{6D4BD85A-A262-44C6-8572-FE3A30410BF3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{026FBC6C-AF76-4568-9B87-EC73457899FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportsExample", "src\Examples\ReportsExample\ReportsExample.csproj", "{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReportsExample", "src\Examples\ReportsExample\ReportsExample.csproj", "{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -88,28 +88,28 @@ Global {73DA578D-A63F-4956-83ED-6D7102E09140}.Release|x86.Build.0 = Release|Any CPU {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x64.ActiveCfg = Debug|x64 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x64.Build.0 = Debug|x64 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x86.ActiveCfg = Debug|x86 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x86.Build.0 = Debug|x86 + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x64.ActiveCfg = Debug|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x64.Build.0 = Debug|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x86.ActiveCfg = Debug|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Debug|x86.Build.0 = Debug|Any CPU {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|Any CPU.Build.0 = Release|Any CPU - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x64.ActiveCfg = Release|x64 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x64.Build.0 = Release|x64 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.ActiveCfg = Release|x86 - {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.Build.0 = Release|x86 + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x64.ActiveCfg = Release|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x64.Build.0 = Release|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.ActiveCfg = Release|Any CPU + {6D4BD85A-A262-44C6-8572-FE3A30410BF3}.Release|x86.Build.0 = Release|Any CPU {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.ActiveCfg = Debug|x64 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.Build.0 = Debug|x64 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.ActiveCfg = Debug|x86 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.Build.0 = Debug|x86 + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.ActiveCfg = Debug|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x64.Build.0 = Debug|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.ActiveCfg = Debug|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Debug|x86.Build.0 = Debug|Any CPU {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|Any CPU.ActiveCfg = Release|Any CPU {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|Any CPU.Build.0 = Release|Any CPU - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.ActiveCfg = Release|x64 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.Build.0 = Release|x64 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.ActiveCfg = Release|x86 - {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.Build.0 = Release|x86 + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.ActiveCfg = Release|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x64.Build.0 = Release|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.ActiveCfg = Release|Any CPU + {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -124,4 +124,7 @@ Global {026FBC6C-AF76-4568-9B87-EC73457899FD} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} {FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D} = {026FBC6C-AF76-4568-9B87-EC73457899FD} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4} + EndGlobalSection EndGlobal diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index 03ac91d4ae..7c8e59e7ac 100755 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -1,13 +1,11 @@ - netcoreapp1.0 + netcoreapp2.0 true JsonApiDotNetCoreExample Exe JsonApiDotNetCoreExample - 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 @@ -15,18 +13,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index f2e6d5ec82..8bb613f413 100755 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,9 +1,7 @@  - netcoreapp1.0 - 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + netcoreapp2.0 @@ -16,11 +14,11 @@ - - - - - + + + + + diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index f50935681a..71c06cac3d 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -3,7 +3,6 @@ netcoreapp1.0 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 diff --git a/src/JsonApiDotNetCore/Internal/JsonApiRouteHandler.cs b/src/JsonApiDotNetCore/Internal/JsonApiRouteHandler.cs index 3099959ef6..6675fc2879 100644 --- a/src/JsonApiDotNetCore/Internal/JsonApiRouteHandler.cs +++ b/src/JsonApiDotNetCore/Internal/JsonApiRouteHandler.cs @@ -51,13 +51,13 @@ public Task RouteAsync(RouteContext context) var candidates = _actionSelector.SelectCandidates(context); if (candidates == null || candidates.Count == 0) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } var actionDescriptor = _actionSelector.SelectBestCandidate(context, candidates); if (actionDescriptor == null) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } context.Handler = (c) => @@ -78,7 +78,7 @@ public Task RouteAsync(RouteContext context) return invoker.InvokeAsync(); }; - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 80f2a0cd77..9a673acc78 100755 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,10 +1,9 @@  - 2.1.3 - netstandard1.6 + 2.2.0 + netcoreapp2.0 JsonApiDotNetCore JsonApiDotNetCore - $(PackageTargetFallback);dnxcore50;portable-net45+win8 jsonapi;dotnet core;emberjs;ember @@ -15,10 +14,10 @@ https://github.com/Research-Institute/json-api-dotnet-core - - - - - + + + + + diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 84bca08a77..7d0c22accc 100755 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -1,15 +1,13 @@  - netcoreapp1.0 + netcoreapp2.0 true JsonApiDotNetCoreExampleTests Exe JsonApiDotNetCoreExampleTests true true - 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 @@ -24,12 +22,12 @@ - - - - + + + + - + diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index a8a6dd1b50..4f20c2d6eb 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,36 +1,31 @@  - netcoreapp1.0 + netcoreapp2.0 true NoEntityFrameworkTests Exe NoEntityFrameworkTests true true - 1.1.1 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 - PreserveNewest - - - - - - + + + + - + diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index d29e136490..c079e9904b 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -1,11 +1,11 @@ - netcoreapp1.1 + netcoreapp2.0 false - - + + From 41693e214073c328805bc63a42840120e5f87add Mon Sep 17 00:00:00 2001 From: Yohan Mishkin Date: Sat, 26 Aug 2017 00:58:04 -0400 Subject: [PATCH 2/7] WIP --- .vscode/tasks.json | 2 +- .../Properties/launchSettings.json | 27 ++++++ .../CamelCasedModelsControllerTests.cs | 15 ++- .../Extensibility/CustomControllerTests.cs | 12 +-- .../Extensibility/RepositoryOverrideTests.cs | 20 ++-- .../Extensibility/RequestMetaTests.cs | 4 +- .../Acceptance/Spec/AttributeFilterTests.cs | 22 ++--- .../Acceptance/Spec/ContentNegotiation.cs | 10 +- .../Acceptance/Spec/CreatingDataTests.cs | 18 ++-- .../Acceptance/Spec/DeletingDataTests.cs | 6 +- .../Acceptance/Spec/DocumentTests/Included.cs | 20 ++-- .../Acceptance/Spec/DocumentTests/Meta.cs | 16 ++-- .../Spec/DocumentTests/PagingTests.cs | 4 +- .../Spec/DocumentTests/Relationships.cs | 4 +- .../Acceptance/Spec/FetchingDataTests.cs | 6 +- .../Spec/FetchingRelationshipsTests.cs | 7 +- .../Acceptance/Spec/QueryParameters.cs | 10 +- .../Acceptance/Spec/SparseFieldSetTests.cs | 20 ++-- .../Acceptance/Spec/UpdatingDataTests.cs | 6 +- .../Spec/UpdatingRelationshipsTests.cs | 8 +- .../Acceptance/TodoItemsControllerTests.cs | 91 ++++++------------- .../Helpers/Startups/AuthorizedStartup.cs | 3 +- .../Startups/ClientGeneratedIdsStartup.cs | 3 +- .../JsonApiDotNetCoreExampleTests.csproj | 2 +- .../TestFixture.cs | 51 +++++++++++ .../WebHostCollection.cs | 6 +- .../Extensibility/NoEntityFrameworkTests.cs | 20 ++-- .../NoEntityFrameworkTests.csproj | 2 +- .../WebHostCollection.cs | 12 --- 29 files changed, 211 insertions(+), 216 deletions(-) create mode 100644 src/Examples/ReportsExample/Properties/launchSettings.json create mode 100644 test/JsonApiDotNetCoreExampleTests/TestFixture.cs delete mode 100644 test/NoEntityFrameworkTests/WebHostCollection.cs diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 725d8335be..09ab6390d4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ "isShellCommand": true, "args": [], "options": { - "cwd": "${workspaceRoot}/src/Examples/JsonApiDotNetCoreExample" + "cwd": "${workspaceRoot}/src/JsonApiDotNetCore" }, "tasks": [ { diff --git a/src/Examples/ReportsExample/Properties/launchSettings.json b/src/Examples/ReportsExample/Properties/launchSettings.json new file mode 100644 index 0000000000..2b84e5d5e8 --- /dev/null +++ b/src/Examples/ReportsExample/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55653/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "ReportsExample": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:55654/" + } + } +} \ No newline at end of file diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs index f41c5941b8..3cc920544f 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs @@ -4,29 +4,27 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCore.Serialization; +using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; using Xunit; -using JsonApiDotNetCore.Services; -using JsonApiDotNetCore.Serialization; -using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.Hosting; namespace JsonApiDotNetCoreExampleTests.Acceptance { [Collection("WebHostCollection")] public class CamelCasedModelsControllerTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private IJsonApiContext _jsonApiContext; private Faker _faker; - public CamelCasedModelsControllerTests(DocsFixture fixture) + public CamelCasedModelsControllerTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); @@ -37,6 +35,7 @@ public CamelCasedModelsControllerTests(DocsFixture fixtu [Fact] public async Task Can_Get_CamelCasedModels() + { // Arrange var model = _faker.Generate(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/CustomControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/CustomControllerTests.cs index 2d1c5623e3..9b28ee48de 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/CustomControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/CustomControllerTests.cs @@ -2,16 +2,14 @@ using System.Net.Http; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Xunit; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Xunit; using Person = JsonApiDotNetCoreExample.Models.Person; namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility @@ -19,11 +17,11 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility [Collection("WebHostCollection")] public class CustomControllerTests { - private DocsFixture _fixture; + private TestFixture _fixture; private Faker _todoItemFaker; private Faker _personFaker; - public CustomControllerTests(DocsFixture fixture) + public CustomControllerTests(TestFixture fixture) { _fixture = fixture; _todoItemFaker = new Faker() diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RepositoryOverrideTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RepositoryOverrideTests.cs index 847d6eefff..2813151ad3 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RepositoryOverrideTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RepositoryOverrideTests.cs @@ -1,27 +1,25 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Xunit; -using JsonApiDotNetCoreExample.Data; -using JsonApiDotNetCoreExampleTests.Startups; -using JsonApiDotNetCoreExample.Models; -using JsonApiDotNetCoreExampleTests.Services; using JsonApiDotNetCore.Serialization; using JsonApiDotNetCore.Services; -using DotNetCoreDocs; using JsonApiDotNetCoreExample; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCoreExample.Data; +using JsonApiDotNetCoreExample.Models; +using JsonApiDotNetCoreExampleTests.Services; +using JsonApiDotNetCoreExampleTests.Startups; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; +using Xunit; namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility { [Collection("WebHostCollection")] public class RepositoryOverrideTests { - private DocsFixture _fixture; + private TestFixture _fixture; - public RepositoryOverrideTests(DocsFixture fixture) + public RepositoryOverrideTests(TestFixture fixture) { _fixture = fixture; } diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs index bc017fa3dc..381972dc20 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs @@ -18,9 +18,9 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility [Collection("WebHostCollection")] public class RequestMetaTests { - private DocsFixture _fixture; + private TestFixture _fixture; - public RequestMetaTests(DocsFixture fixture) + public RequestMetaTests(TestFixture fixture) { _fixture = fixture; } diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/AttributeFilterTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/AttributeFilterTests.cs index 42c3f0b1f1..740a61193c 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/AttributeFilterTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/AttributeFilterTests.cs @@ -1,31 +1,29 @@ -using System.Net; +using System.Linq; +using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; +using Bogus; +using JsonApiDotNetCore.Models; +using JsonApiDotNetCore.Serialization; using JsonApiDotNetCoreExample; +using JsonApiDotNetCoreExample.Data; +using JsonApiDotNetCoreExample.Models; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; +using Newtonsoft.Json; using Xunit; -using JsonApiDotNetCoreExample.Data; -using Bogus; -using JsonApiDotNetCoreExample.Models; -using JsonApiDotNetCore.Serialization; -using System.Linq; using Person = JsonApiDotNetCoreExample.Models.Person; -using Newtonsoft.Json; -using JsonApiDotNetCore.Models; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec { [Collection("WebHostCollection")] public class AttributeFilterTests { - private DocsFixture _fixture; + private TestFixture _fixture; private Faker _todoItemFaker; private readonly Faker _personFaker; - public AttributeFilterTests(DocsFixture fixture) + public AttributeFilterTests(TestFixture fixture) { _fixture = fixture; _todoItemFaker = new Faker() diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/ContentNegotiation.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/ContentNegotiation.cs index 8fba782c8c..8f76735ee9 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/ContentNegotiation.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/ContentNegotiation.cs @@ -2,9 +2,6 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Models; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; @@ -15,8 +12,8 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class ContentNegotiation { - private DocsFixture _fixture; - public ContentNegotiation(DocsFixture fixture) + private TestFixture _fixture; + public ContentNegotiation(TestFixture fixture) { _fixture = fixture; } @@ -29,7 +26,6 @@ public async Task Server_Sends_Correct_ContentType_Header() .UseStartup(); var httpMethod = new HttpMethod("GET"); var route = "/api/v1/todo-items"; - var description = new RequestProperties("Server Sends Correct Content Type Header"); var server = new TestServer(builder); var client = server.CreateClient(); var request = new HttpRequestMessage(httpMethod, route); @@ -50,7 +46,6 @@ public async Task Server_Responds_415_With_MediaType_Parameters() .UseStartup(); var httpMethod = new HttpMethod("GET"); var route = "/api/v1/todo-items"; - var description = new RequestProperties("Server responds with 415 if request contains media type parameters"); var server = new TestServer(builder); var client = server.CreateClient(); var request = new HttpRequestMessage(httpMethod, route); @@ -73,7 +68,6 @@ public async Task ServerResponds_406_If_RequestAcceptHeader_Contains_MediaTypePa .UseStartup(); var httpMethod = new HttpMethod("GET"); var route = "/api/v1/todo-items"; - var description = new RequestProperties("Server responds with 406..."); var server = new TestServer(builder); var client = server.CreateClient(); var acceptHeader = new MediaTypeWithQualityHeaderValue("application/vnd.api+json"); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs index 08db60d635..e011cb8679 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs @@ -1,35 +1,33 @@ -using System.Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCore.Serialization; using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; +using JsonApiDotNetCoreExampleTests.Startups; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Xunit; -using System.Collections.Generic; -using System.Linq; -using Microsoft.EntityFrameworkCore; -using JsonApiDotNetCoreExampleTests.Startups; -using System; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec { [Collection("WebHostCollection")] public class CreatingDataTests { - private DocsFixture _fixture; + private TestFixture _fixture; private IJsonApiContext _jsonApiContext; private Faker _todoItemFaker; - public CreatingDataTests(DocsFixture fixture) + public CreatingDataTests(TestFixture fixture) { _fixture = fixture; _jsonApiContext = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DeletingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DeletingDataTests.cs index 46ac64810e..8ddb9a56a1 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DeletingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DeletingDataTests.cs @@ -3,8 +3,6 @@ using System.Net.Http; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; @@ -17,11 +15,11 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class DeletingDataTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private Faker _todoItemFaker; - public DeletingDataTests(DocsFixture fixture) + public DeletingDataTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs index e782f18aa9..6ca456d680 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs @@ -1,32 +1,30 @@ -using System.Net; +using System.Linq; +using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; +using Bogus; +using JsonApiDotNetCore.Models; using JsonApiDotNetCoreExample; +using JsonApiDotNetCoreExample.Data; +using JsonApiDotNetCoreExample.Models; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; using Xunit; using Person = JsonApiDotNetCoreExample.Models.Person; -using JsonApiDotNetCore.Models; -using JsonApiDotNetCoreExample.Data; -using Bogus; -using JsonApiDotNetCoreExample.Models; -using System.Linq; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec.DocumentTests { [Collection("WebHostCollection")] public class Included { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; - private Faker _personFaker; + private Bogus.Faker _personFaker; private Faker _todoItemFaker; private Faker _todoItemCollectionFaker; - public Included(DocsFixture fixture) + public Included(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Meta.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Meta.cs index 4fb7693d4c..5316753245 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Meta.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Meta.cs @@ -1,27 +1,25 @@ +using System.Collections; using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCore.Models; using JsonApiDotNetCoreExample; +using JsonApiDotNetCoreExample.Data; +using JsonApiDotNetCoreExample.Models; +using JsonApiDotNetCoreExampleTests.Startups; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; using Xunit; -using JsonApiDotNetCore.Models; -using JsonApiDotNetCoreExample.Data; -using JsonApiDotNetCoreExampleTests.Startups; -using JsonApiDotNetCoreExample.Models; -using System.Collections; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec.DocumentTests { [Collection("WebHostCollection")] public class Meta { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; - public Meta(DocsFixture fixture) + public Meta(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs index f8d412a153..1fa7a7b71c 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs @@ -20,13 +20,13 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec.DocumentTests [Collection("WebHostCollection")] public class PagingTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private Faker _personFaker; private Faker _todoItemFaker; private Faker _todoItemCollectionFaker; - public PagingTests(DocsFixture fixture) + public PagingTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs index 76efe6f068..8976d0eb72 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs @@ -19,11 +19,11 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec.DocumentTests [Collection("WebHostCollection")] public class Relationships { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private Faker _todoItemFaker; - public Relationships(DocsFixture fixture) + public Relationships(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingDataTests.cs index fc57326d55..208ec2f72d 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingDataTests.cs @@ -3,8 +3,6 @@ using System.Net.Http; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCore.Models; using JsonApiDotNetCore.Serialization; using JsonApiDotNetCore.Services; @@ -22,12 +20,12 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class FetchingDataTests { - private DocsFixture _fixture; + private TestFixture _fixture; private IJsonApiContext _jsonApiContext; private Faker _todoItemFaker; private Faker _personFaker; - public FetchingDataTests(DocsFixture fixture) + public FetchingDataTests(TestFixture fixture) { _fixture = fixture; _jsonApiContext = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs index 6825f98751..51356222ba 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs @@ -3,8 +3,6 @@ using System.Net.Http; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; @@ -12,16 +10,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Xunit; + namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec { [Collection("WebHostCollection")] public class FetchingRelationshipsTests { - private DocsFixture _fixture; + private TestFixture _fixture; private IJsonApiContext _jsonApiContext; private Faker _todoItemFaker; - public FetchingRelationshipsTests(DocsFixture fixture) + public FetchingRelationshipsTests(TestFixture fixture) { _fixture = fixture; _jsonApiContext = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/QueryParameters.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/QueryParameters.cs index a67b380838..c5a02cb6b7 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/QueryParameters.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/QueryParameters.cs @@ -1,23 +1,20 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Models; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCore.Internal; using JsonApiDotNetCoreExample; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; using Xunit; -using JsonApiDotNetCore.Internal; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec { [Collection("WebHostCollection")] public class QueryParameters { - private DocsFixture _fixture; - public QueryParameters(DocsFixture fixture) + private TestFixture _fixture; + public QueryParameters(TestFixture fixture) { _fixture = fixture; } @@ -32,7 +29,6 @@ public async Task Server_Returns_400_ForUnknownQueryParam() .UseStartup(); var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?{queryKey}={queryValue}"; - var description = new RequestProperties("Server Returns 400 For Unknown Query Params"); var server = new TestServer(builder); var client = server.CreateClient(); var request = new HttpRequestMessage(httpMethod, route); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs index d23eda4cc8..8c5c6b5249 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/SparseFieldSetTests.cs @@ -1,21 +1,19 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCore.Extensions; +using JsonApiDotNetCore.Models; using JsonApiDotNetCoreExample; -using Xunit; -using Microsoft.EntityFrameworkCore; using JsonApiDotNetCoreExample.Data; -using JsonApiDotNetCore.Extensions; using JsonApiDotNetCoreExample.Models; -using System.Linq; +using JsonApiDotNetCoreExampleTests.Helpers.Extensions; using Microsoft.AspNetCore.Hosting; -using System.Net.Http; using Microsoft.AspNetCore.TestHost; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; -using JsonApiDotNetCore.Models; -using JsonApiDotNetCoreExampleTests.Helpers.Extensions; +using Xunit; using StringExtensions = JsonApiDotNetCoreExampleTests.Helpers.Extensions.StringExtensions; namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec @@ -23,10 +21,10 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class SparseFieldSetTests { - private DocsFixture _fixture; + private TestFixture _fixture; private readonly AppDbContext _dbContext; - public SparseFieldSetTests(DocsFixture fixture) + public SparseFieldSetTests(TestFixture fixture) { _fixture = fixture; _dbContext = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs index 5e8c0f3634..d39f69a855 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs @@ -5,8 +5,6 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; @@ -22,12 +20,12 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class UpdatingDataTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private Faker _todoItemFaker; private Faker _personFaker; - public UpdatingDataTests(DocsFixture fixture) + public UpdatingDataTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs index 39cb4dbdd0..d17a10c1d7 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs @@ -5,8 +5,6 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; @@ -22,12 +20,12 @@ namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec [Collection("WebHostCollection")] public class UpdatingRelationshipsTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; - private Faker _personFaker; + private Bogus.Faker _personFaker; private Faker _todoItemFaker; - public UpdatingRelationshipsTests(DocsFixture fixture) + public UpdatingRelationshipsTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs index 13c6d8e78c..e2fe964217 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs @@ -1,33 +1,31 @@ using System.Collections.Generic; +using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; using DotNetCoreDocs.Models; -using DotNetCoreDocs.Writers; +using JsonApiDotNetCore.Serialization; +using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; -using Person = JsonApiDotNetCoreExample.Models.Person; using Newtonsoft.Json; using Xunit; -using JsonApiDotNetCore.Services; -using JsonApiDotNetCore.Serialization; -using System.Linq; +using Person = JsonApiDotNetCoreExample.Models.Person; namespace JsonApiDotNetCoreExampleTests.Acceptance { [Collection("WebHostCollection")] public class TodoItemControllerTests { - private DocsFixture _fixture; + private TestFixture _fixture; private AppDbContext _context; private IJsonApiContext _jsonApiContext; private Faker _todoItemFaker; - public TodoItemControllerTests(DocsFixture fixture) + public TodoItemControllerTests(TestFixture fixture) { _fixture = fixture; _context = fixture.GetService(); @@ -51,11 +49,10 @@ public async Task Can_Get_TodoItems() var httpMethod = new HttpMethod("GET"); var route = "/api/v1/todo-items"; - - var description = new RequestProperties("Get TodoItems"); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -78,13 +75,10 @@ public async Task Can_Paginate_TodoItems() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?page[size]={expectedEntitiesPerPage}"; - - var description = new RequestProperties("Paginate TodoItems", new Dictionary { - { "?page[size]=", "Number of entities per page" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -107,13 +101,10 @@ public async Task Can_Filter_TodoItems() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?filter[ordinal]={todoItem.Ordinal}"; - - var description = new RequestProperties("Filter TodoItems By Attribute", new Dictionary { - { "?filter[...]=", "Filter on attribute" } - }); - + var request = new HttpRequestMessage(httpMethod, route); + // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -137,13 +128,10 @@ public async Task Can_Filter_TodoItems_Using_Like_Operator() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?filter[description]=like:{substring}"; - - var description = new RequestProperties("Filter TodoItems Where Attribute Like", new Dictionary { - { "?filter[...]=", "Filter on attribute" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -175,13 +163,10 @@ public async Task Can_Sort_TodoItems_By_Ordinal_Ascending() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?sort=ordinal"; - - var description = new RequestProperties("Sort TodoItems Ascending", new Dictionary { - { "?sort=attr", "Sort on attribute" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -217,13 +202,10 @@ public async Task Can_Sort_TodoItems_By_Ordinal_Descending() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?sort=-ordinal"; - - var description = new RequestProperties("Sort TodoItems Descending", new Dictionary { - { "?sort=-attr", "Sort on attribute" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = _fixture.GetService().DeserializeList(body); @@ -251,13 +233,10 @@ public async Task Can_Get_TodoItem_ById() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items/{todoItem.Id}"; - - var description = new RequestProperties("Get TodoItem By Id", new Dictionary { - { "/todo-items/{id}", "TodoItem Id" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -282,14 +261,10 @@ public async Task Can_Get_TodoItem_WithOwner() var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items/{todoItem.Id}?include=owner"; - - var description = new RequestProperties("Get TodoItem By Id", new Dictionary { - { "/todo-items/{id}", "TodoItem Id" }, - { "?include={relationship}", "Included Relationship" } - }); + var request = new HttpRequestMessage(httpMethod, route); // Act - var response = await _fixture.MakeRequest(description, httpMethod, route); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -344,10 +319,8 @@ public async Task Can_Post_TodoItem() request.Content = new StringContent(JsonConvert.SerializeObject(content)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.api+json"); - var description = new RequestProperties("Post TodoItem"); - // Act - var response = await _fixture.MakeRequest(description, request); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -393,11 +366,9 @@ public async Task Can_Patch_TodoItem() var request = new HttpRequestMessage(httpMethod, route); request.Content = new StringContent(JsonConvert.SerializeObject(content)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.api+json"); - - var description = new RequestProperties("Patch TodoItem"); - + // Act - var response = await _fixture.MakeRequest(description, request); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -448,10 +419,8 @@ public async Task Can_Patch_TodoItemWithNullable() request.Content = new StringContent(JsonConvert.SerializeObject(content)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.api+json"); - var description = new RequestProperties("Patch TodoItem"); - // Act - var response = await _fixture.MakeRequest(description, request); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -501,10 +470,8 @@ public async Task Can_Patch_TodoItemWithNullValue() request.Content = new StringContent(JsonConvert.SerializeObject(content)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.api+json"); - var description = new RequestProperties("Patch TodoItem"); - // Act - var response = await _fixture.MakeRequest(description, request); + var response = await _fixture.Client.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItem)_fixture.GetService().Deserialize(body); @@ -539,7 +506,7 @@ public async Task Can_Delete_TodoItem() var description = new RequestProperties("Delete TodoItem"); // Act - var response = await _fixture.MakeRequest(description, request); + var response = await _fixture.Client.SendAsync(request); // Assert Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs index b9272e2de7..836d702b88 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs @@ -25,8 +25,7 @@ public override IServiceProvider ConfigureServices(IServiceCollection services) { var loggerFactory = new LoggerFactory(); - loggerFactory - .AddConsole(LogLevel.Trace); + loggerFactory.AddConsole(); services.AddSingleton(loggerFactory); diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs index 30a8dca6fa..aa144c6e27 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs @@ -20,8 +20,7 @@ public override IServiceProvider ConfigureServices(IServiceCollection services) { var loggerFactory = new LoggerFactory(); - loggerFactory - .AddConsole(LogLevel.Trace); + loggerFactory.AddConsole(); services.AddSingleton(loggerFactory); diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 7d0c22accc..8193311bfc 100755 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -25,7 +25,7 @@ - + diff --git a/test/JsonApiDotNetCoreExampleTests/TestFixture.cs b/test/JsonApiDotNetCoreExampleTests/TestFixture.cs new file mode 100644 index 0000000000..424163f956 --- /dev/null +++ b/test/JsonApiDotNetCoreExampleTests/TestFixture.cs @@ -0,0 +1,51 @@ +using System; +using System.Net.Http; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; + +namespace JsonApiDotNetCoreExampleTests +{ + public class TestFixture : IDisposable + where TStartup : class + { + private readonly TestServer _server; + private IServiceProvider _services; + + public TestFixture() + { + var builder = new WebHostBuilder() + .UseStartup(); + + _server = new TestServer(builder); + _services = _server.Host.Services; + Client = _server.CreateClient(); + } + + public HttpClient Client { get; set; } + + public T GetService() + { + return (T)_services.GetService(typeof(T)); + } + + private bool disposedValue = false; + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + Client.Dispose(); + _server.Dispose(); + } + + disposedValue = true; + } + } + + public void Dispose() + { + Dispose(true); + } + } +} \ No newline at end of file diff --git a/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs b/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs index 6cbc0508a9..01b3ace217 100644 --- a/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs +++ b/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs @@ -1,12 +1,10 @@ -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using Xunit; namespace JsonApiDotNetCoreExampleTests { [CollectionDefinition("WebHostCollection")] - public class WebHostCollection - : ICollectionFixture> + public class WebHostCollection + : ICollectionFixture> { } } diff --git a/test/NoEntityFrameworkTests/Acceptance/Extensibility/NoEntityFrameworkTests.cs b/test/NoEntityFrameworkTests/Acceptance/Extensibility/NoEntityFrameworkTests.cs index 3a2166a3d3..41a48f2743 100644 --- a/test/NoEntityFrameworkTests/Acceptance/Extensibility/NoEntityFrameworkTests.cs +++ b/test/NoEntityFrameworkTests/Acceptance/Extensibility/NoEntityFrameworkTests.cs @@ -1,17 +1,17 @@ -using JsonApiDotNetCore.Serialization; -using Xunit; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using NoEntityFrameworkExample; +using System; +using System.Net; using System.Net.Http; -using JsonApiDotNetCoreExampleTests.Helpers.Extensions; +using System.Net.Http.Headers; using System.Threading.Tasks; -using System.Net; -using JsonApiDotNetCoreExample.Models; +using JsonApiDotNetCore.Serialization; using JsonApiDotNetCoreExample.Data; -using System; +using JsonApiDotNetCoreExample.Models; +using JsonApiDotNetCoreExampleTests.Helpers.Extensions; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; using Newtonsoft.Json; -using System.Net.Http.Headers; +using NoEntityFrameworkExample; +using Xunit; namespace NoEntityFrameworkTests.Acceptance.Extensibility { diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 4f20c2d6eb..bc95db3575 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -23,7 +23,7 @@ - + diff --git a/test/NoEntityFrameworkTests/WebHostCollection.cs b/test/NoEntityFrameworkTests/WebHostCollection.cs deleted file mode 100644 index 071b1fcf81..0000000000 --- a/test/NoEntityFrameworkTests/WebHostCollection.cs +++ /dev/null @@ -1,12 +0,0 @@ -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; -using JsonApiDotNetCoreExample; -using Xunit; - -namespace NoEntityFrameworkTests -{ - [CollectionDefinition("WebHostCollection")] - public class WebHostCollection - : ICollectionFixture> - { } -} From 52c08afe446dde66199ccb560bcfcbb0203837b7 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 5 Dec 2017 05:51:59 -0600 Subject: [PATCH 3/7] chore(*): move all dependencies in Directory.Build.props file and fix build errors --- Directory.Build.props | 26 ++++++++++++++++++ .../JsonApiDotNetCoreExample.csproj | 27 +++++++++---------- .../JsonApiDotNetCoreExample/Startup.cs | 14 ++-------- .../JsonApiDotNetCoreExample/appsettings.json | 8 ++---- .../NoEntityFrameworkExample.csproj | 12 ++++----- .../ReportsExample/ReportsExample.csproj | 13 +++++---- .../JsonApiDotNetCore.csproj | 12 ++++----- .../Extensibility/RequestMetaTests.cs | 2 -- .../Spec/DocumentTests/PagingTests.cs | 2 -- .../Spec/DocumentTests/Relationships.cs | 2 -- .../Acceptance/TodoItemsControllerTests.cs | 3 --- .../Helpers/Startups/AuthorizedStartup.cs | 3 --- .../Startups/ClientGeneratedIdsStartup.cs | 3 --- .../Helpers/Startups/MetaStartup.cs | 2 -- .../JsonApiDotNetCoreExampleTests.csproj | 11 ++++---- .../JsonApiDotNetCoreExampleTests.sln | 17 ++++++++++++ .../appsettings.json | 10 +++---- .../NoEntityFrameworkTests.csproj | 10 +++---- test/NoEntityFrameworkTests/appsettings.json | 10 +++---- test/UnitTests/UnitTests.csproj | 14 +++++----- 20 files changed, 102 insertions(+), 99 deletions(-) create mode 100644 Directory.Build.props create mode 100644 test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..d3e19546db --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,26 @@ + + + + netstandard2.0 + 2.0.1 + 2.0.1 + 2.0.0 + 2.0.0 + 4.4.0 + + + + + netcoreapp2.0 + 2.0.0 + 2.0.0 + 3.2.6 + 2.0.1 + 15.3.0-preview-20170427-09 + 1.1.2 + 2.3.0-beta3-build3705 + 15.0.3 + 4.7.99 + + + \ No newline at end of file diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index 7c8e59e7ac..e9971a1113 100755 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -13,23 +13,22 @@ - - - - - - - - - - - - - + + + + + + + + + + + + - + diff --git a/src/Examples/JsonApiDotNetCoreExample/Startup.cs b/src/Examples/JsonApiDotNetCoreExample/Startup.cs index 4a4f591967..9683eb033d 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Startup.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Startup.cs @@ -6,8 +6,6 @@ using JsonApiDotNetCoreExample.Data; using Microsoft.EntityFrameworkCore; using JsonApiDotNetCore.Extensions; -using DotNetCoreDocs.Configuration; -using DotNetCoreDocs.Middleware; using System; namespace JsonApiDotNetCoreExample @@ -30,8 +28,7 @@ public Startup(IHostingEnvironment env) public virtual IServiceProvider ConfigureServices(IServiceCollection services) { var loggerFactory = new LoggerFactory(); - loggerFactory - .AddConsole(LogLevel.Trace); + loggerFactory.AddConsole(LogLevel.Trace); services.AddSingleton(loggerFactory); services.AddDbContext(options => @@ -46,8 +43,6 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services) opt.IncludeTotalRecordCount = true; }); - services.AddDocumentationConfiguration(Config); - var provider = services.BuildServiceProvider(); var appContext = provider.GetRequiredService(); if(appContext == null) @@ -67,14 +62,9 @@ public virtual void Configure( loggerFactory.AddConsole(Config.GetSection("Logging")); loggerFactory.AddDebug(); - app.UseDocs(); - app.UseJsonApi(); } - public string GetDbConnectionString() - { - return Config["Data:DefaultConnection"]; - } + public string GetDbConnectionString() => Config["Data:DefaultConnection"]; } } \ No newline at end of file diff --git a/src/Examples/JsonApiDotNetCoreExample/appsettings.json b/src/Examples/JsonApiDotNetCoreExample/appsettings.json index bd84450b47..ceb4a1ed73 100755 --- a/src/Examples/JsonApiDotNetCoreExample/appsettings.json +++ b/src/Examples/JsonApiDotNetCoreExample/appsettings.json @@ -1,6 +1,7 @@ { "Data": { - "DefaultConnection": "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=password" + "DefaultConnection": + "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=password" }, "Logging": { "IncludeScopes": false, @@ -9,10 +10,5 @@ "System": "Trace", "Microsoft": "Trace" } - }, - "DocsConfiguration": { - "BaseAddress": "http://localhost:5000", - "RequestsDirectory": "../../src/JsonApiDotNetCoreExample/_data", - "DocumentationRoute": "/docs" } } diff --git a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj index 8bb613f413..afaf0e7cff 100755 --- a/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj +++ b/src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + $(NetCoreAppVersion) @@ -14,11 +14,11 @@ - - - - - + + + + + diff --git a/src/Examples/ReportsExample/ReportsExample.csproj b/src/Examples/ReportsExample/ReportsExample.csproj index 71c06cac3d..2131c545a4 100644 --- a/src/Examples/ReportsExample/ReportsExample.csproj +++ b/src/Examples/ReportsExample/ReportsExample.csproj @@ -1,8 +1,7 @@ - netcoreapp1.0 - 1.1.1 + $(NetCoreAppVersion) @@ -14,11 +13,11 @@ - - - - - + + + + + diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 9a673acc78..26e3d12ed3 100755 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,7 +1,7 @@  2.2.0 - netcoreapp2.0 + $(NetStandardVersion) JsonApiDotNetCore JsonApiDotNetCore @@ -14,10 +14,10 @@ https://github.com/Research-Institute/json-api-dotnet-core - - - - - + + + + + diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs index 381972dc20..9420ea6891 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/RequestMetaTests.cs @@ -5,9 +5,7 @@ using Microsoft.AspNetCore.TestHost; using Xunit; using JsonApiDotNetCoreExample.Models; -using DotNetCoreDocs; using JsonApiDotNetCoreExample; -using DotNetCoreDocs.Writers; using Newtonsoft.Json; using JsonApiDotNetCore.Models; using System.Collections; diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs index 1fa7a7b71c..0aa4ede88b 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/PagingTests.cs @@ -1,8 +1,6 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs index 8976d0eb72..5c0018354d 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Relationships.cs @@ -1,8 +1,6 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using DotNetCoreDocs; -using DotNetCoreDocs.Writers; using JsonApiDotNetCoreExample; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs index e2fe964217..da1e3f0804 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs @@ -5,7 +5,6 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs.Models; using JsonApiDotNetCore.Serialization; using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; @@ -503,8 +502,6 @@ public async Task Can_Delete_TodoItem() request.Content = new StringContent(string.Empty); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.api+json"); - var description = new RequestProperties("Delete TodoItem"); - // Act var response = await _fixture.Client.SendAsync(request); diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs index 836d702b88..21cfa0e0dc 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/AuthorizedStartup.cs @@ -4,7 +4,6 @@ using JsonApiDotNetCoreExample.Data; using Microsoft.EntityFrameworkCore; using JsonApiDotNetCore.Extensions; -using DotNetCoreDocs.Configuration; using System; using JsonApiDotNetCoreExample; using Moq; @@ -47,8 +46,6 @@ public override IServiceProvider ConfigureServices(IServiceCollection services) services.AddSingleton(authServicMock.Object); services.AddScoped, AuthorizedTodoItemsRepository>(); - services.AddDocumentationConfiguration(Config); - return services.BuildServiceProvider(); } } diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs index aa144c6e27..32d8186802 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/ClientGeneratedIdsStartup.cs @@ -4,7 +4,6 @@ using JsonApiDotNetCoreExample.Data; using Microsoft.EntityFrameworkCore; using JsonApiDotNetCore.Extensions; -using DotNetCoreDocs.Configuration; using System; using JsonApiDotNetCoreExample; @@ -37,8 +36,6 @@ public override IServiceProvider ConfigureServices(IServiceCollection services) opt.AllowClientGeneratedIds = true; }); - services.AddDocumentationConfiguration(Config); - return services.BuildServiceProvider(); } } diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/MetaStartup.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/MetaStartup.cs index b23fded9ba..0001878a50 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/MetaStartup.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Startups/MetaStartup.cs @@ -4,7 +4,6 @@ using JsonApiDotNetCoreExample.Data; using Microsoft.EntityFrameworkCore; using JsonApiDotNetCore.Extensions; -using DotNetCoreDocs.Configuration; using System; using JsonApiDotNetCoreExample; using JsonApiDotNetCore.Services; @@ -39,7 +38,6 @@ public override IServiceProvider ConfigureServices(IServiceCollection services) opt.IncludeTotalRecordCount = true; }); - services.AddDocumentationConfiguration(Config); services.AddScoped(); return services.BuildServiceProvider(); diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj index 8193311bfc..b22953dc23 100755 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + $(NetCoreAppVersion) true JsonApiDotNetCoreExampleTests Exe @@ -22,12 +22,13 @@ - + + - - + + - + diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln new file mode 100644 index 0000000000..87d08fd486 --- /dev/null +++ b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 15.00 +# Visual Studio 2017 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCoreExampleTests", "JsonApiDotNetCoreExampleTests.csproj", "{54F94127-E63E-4ADA-9B20-367EC2F6E3D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54F94127-E63E-4ADA-9B20-367EC2F6E3D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54F94127-E63E-4ADA-9B20-367EC2F6E3D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54F94127-E63E-4ADA-9B20-367EC2F6E3D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54F94127-E63E-4ADA-9B20-367EC2F6E3D6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/JsonApiDotNetCoreExampleTests/appsettings.json b/test/JsonApiDotNetCoreExampleTests/appsettings.json index 40ed14033f..7067b2bee0 100644 --- a/test/JsonApiDotNetCoreExampleTests/appsettings.json +++ b/test/JsonApiDotNetCoreExampleTests/appsettings.json @@ -1,6 +1,7 @@ { "Data": { - "DefaultConnection": "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=" + "DefaultConnection": + "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=" }, "Logging": { "IncludeScopes": false, @@ -9,10 +10,5 @@ "System": "Information", "Microsoft": "Information" } - }, - "DocsConfiguration": { - "BaseAddress": "http://localhost:5000", - "RequestsDirectory": "../../src/JsonApiDotNetCoreExample/_data", - "DocumentationRoute": "/docs" } -} \ No newline at end of file +} diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index bc95db3575..8daa7dc9af 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + $(NetCoreAppVersion) true NoEntityFrameworkTests Exe @@ -20,12 +20,12 @@ - + - - + + - + diff --git a/test/NoEntityFrameworkTests/appsettings.json b/test/NoEntityFrameworkTests/appsettings.json index 40ed14033f..7067b2bee0 100644 --- a/test/NoEntityFrameworkTests/appsettings.json +++ b/test/NoEntityFrameworkTests/appsettings.json @@ -1,6 +1,7 @@ { "Data": { - "DefaultConnection": "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=" + "DefaultConnection": + "Host=localhost;Port=5432;Database=JsonApiDotNetCoreExample;User ID=postgres;Password=" }, "Logging": { "IncludeScopes": false, @@ -9,10 +10,5 @@ "System": "Information", "Microsoft": "Information" } - }, - "DocsConfiguration": { - "BaseAddress": "http://localhost:5000", - "RequestsDirectory": "../../src/JsonApiDotNetCoreExample/_data", - "DocumentationRoute": "/docs" } -} \ No newline at end of file +} diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index c079e9904b..dcd659d2df 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -1,16 +1,16 @@ - netcoreapp2.0 + $(NetCoreAppVersion) false - - - - - - + + + + + + \ No newline at end of file From 0366d026595ea2798bb29bb87680c9e3e9d268b3 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 5 Dec 2017 06:56:15 -0600 Subject: [PATCH 4/7] test(*): fix tests broken after aspnet and ef core 2.0 upgrades --- .../Acceptance/Spec/CreatingDataTests.cs | 2 + .../Acceptance/Spec/DocumentTests/Included.cs | 22 +++++--- .../Spec/FetchingRelationshipsTests.cs | 6 ++- .../Acceptance/Spec/PagingTests.cs | 29 +++-------- .../Spec/UpdatingRelationshipsTests.cs | 1 + .../Acceptance/TestFixture.cs | 23 ++++++++- .../Extensions/IQueryableExtensions.cs | 9 ++-- .../TestFixture.cs | 51 ------------------- .../WebHostCollection.cs | 1 + .../appsettings.json | 2 +- 10 files changed, 61 insertions(+), 85 deletions(-) delete mode 100644 test/JsonApiDotNetCoreExampleTests/TestFixture.cs diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs index e011cb8679..2f461c4f74 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/CreatingDataTests.cs @@ -272,6 +272,8 @@ public async Task Can_Create_And_Set_HasMany_Relationships() var body = await response.Content.ReadAsStringAsync(); var deserializedBody = (TodoItemCollection)_fixture.GetService().Deserialize(body); var newId = deserializedBody.Id; + + context = _fixture.GetService(); var contextCollection = context.TodoItemCollections .Include(c => c.Owner) .Include(c => c.TodoItems) diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs index 6ca456d680..5d4a4aa4e2 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -45,8 +46,14 @@ public Included(TestFixture fixture) public async Task GET_Included_Contains_SideloadedData_ForManyToOne() { // arrange - var builder = new WebHostBuilder() - .UseStartup(); + var person = _personFaker.Generate(); + var todoItem = _todoItemFaker.Generate(); + todoItem.Owner = person; + _context.TodoItems.RemoveRange(_context.TodoItems); + _context.TodoItems.Add(todoItem); + _context.SaveChanges(); + + var builder = new WebHostBuilder().UseStartup(); var httpMethod = new HttpMethod("GET"); var route = $"/api/v1/todo-items?include=owner"; @@ -57,13 +64,16 @@ public async Task GET_Included_Contains_SideloadedData_ForManyToOne() // act var response = await client.SendAsync(request); - var documents = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - var data = documents.Data[0]; // assert + var json = await response.Content.ReadAsStringAsync(); + var documents = JsonConvert.DeserializeObject(json); + // we only care about counting the todo-items that have owners + var expectedCount = documents.Data.Count(d => d.Relationships["owner"].SingleData != null); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotEmpty(documents.Included); - Assert.Equal(documents.Data.Count, documents.Included.Count); + Assert.Equal(expectedCount, documents.Included.Count); } [Fact] diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs index 51356222ba..ea805c515f 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/FetchingRelationshipsTests.cs @@ -66,7 +66,11 @@ public async Task Request_ForRelationshipLink_ThatDoesNotExist_Returns_404() { // arrange var context = _fixture.GetService(); - var todoItem = context.TodoItems.First(); + + var todoItem = _todoItemFaker.Generate(); + context.TodoItems.Add(todoItem); + await context.SaveChangesAsync(); + var todoItemId = todoItem.Id; context.TodoItems.Remove(todoItem); await context.SaveChangesAsync(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/PagingTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/PagingTests.cs index ea99cb7d59..02dbd019e0 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/PagingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/PagingTests.cs @@ -1,33 +1,22 @@ -using System.Collections.Generic; -using System; using System.Linq; using System.Net; -using System.Net.Http; using System.Threading.Tasks; using Bogus; -using DotNetCoreDocs; -using DotNetCoreDocs.Models; -using DotNetCoreDocs.Writers; using JsonApiDotNetCore.Serialization; -using JsonApiDotNetCore.Services; using JsonApiDotNetCoreExample; -using JsonApiDotNetCoreExample.Data; using JsonApiDotNetCoreExample.Models; using Xunit; using Person = JsonApiDotNetCoreExample.Models.Person; -namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec -{ - public class PagingTests : TestFixture - { +namespace JsonApiDotNetCoreExampleTests.Acceptance.Spec { + public class PagingTests : TestFixture { private readonly Faker _todoItemFaker = new Faker() - .RuleFor(t => t.Description, f => f.Lorem.Sentence()) - .RuleFor(t => t.Ordinal, f => f.Random.Number()) - .RuleFor(t => t.CreatedDate, f => f.Date.Past()); + .RuleFor(t => t.Description, f => f.Lorem.Sentence()) + .RuleFor(t => t.Ordinal, f => f.Random.Number()) + .RuleFor(t => t.CreatedDate, f => f.Date.Past()); [Fact] - public async Task Can_Paginate_TodoItems() - { + public async Task Can_Paginate_TodoItems() { // Arrange const int expectedEntitiesPerPage = 2; var totalCount = expectedEntitiesPerPage * 2; @@ -56,8 +45,7 @@ public async Task Can_Paginate_TodoItems() } [Fact] - public async Task Can_Paginate_TodoItems_From_Start() - { + public async Task Can_Paginate_TodoItems_From_Start() { // Arrange const int expectedEntitiesPerPage = 2; var totalCount = expectedEntitiesPerPage * 2; @@ -91,8 +79,7 @@ public async Task Can_Paginate_TodoItems_From_Start() } [Fact] - public async Task Can_Paginate_TodoItems_From_End() - { + public async Task Can_Paginate_TodoItems_From_End() { // Arrange const int expectedEntitiesPerPage = 2; var totalCount = expectedEntitiesPerPage * 2; diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs index d17a10c1d7..5cc3772497 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingRelationshipsTests.cs @@ -77,6 +77,7 @@ public async Task Can_Update_ToMany_Relationship_ThroughLink() // Act var response = await client.SendAsync(request); + _context = _fixture.GetService(); var personsTodoItems = _context.People.Include(p => p.TodoItems).Single(p => p.Id == person.Id).TodoItems; // Assert diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/TestFixture.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/TestFixture.cs index 0379eae91d..d7ec6868b9 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/TestFixture.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/TestFixture.cs @@ -5,11 +5,10 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using JsonApiDotNetCore.Services; -using Newtonsoft.Json; namespace JsonApiDotNetCoreExampleTests.Acceptance { - public class TestFixture where TStartup : class + public class TestFixture : IDisposable where TStartup : class { private readonly TestServer _server; private IServiceProvider _services; @@ -33,5 +32,25 @@ public TestFixture() public IJsonApiDeSerializer DeSerializer { get; private set; } public IJsonApiContext JsonApiContext { get; private set; } public T GetService() => (T)_services.GetService(typeof(T)); + + private bool disposedValue = false; + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + Client.Dispose(); + _server.Dispose(); + } + + disposedValue = true; + } + } + + public void Dispose() + { + Dispose(true); + } } } \ No newline at end of file diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs index a40dfb4a5a..c774478227 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs @@ -4,12 +4,12 @@ using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.Internal; +using Microsoft.EntityFrameworkCore.Storage; using Remotion.Linq.Parsing.Structure; using Database = Microsoft.EntityFrameworkCore.Storage.Database; namespace JsonApiDotNetCoreExampleTests.Helpers.Extensions { - public static class IQueryableExtensions { private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo(); @@ -22,19 +22,22 @@ public static class IQueryableExtensions private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database"); - private static readonly FieldInfo QueryCompilationContextFactoryField = typeof(Database).GetTypeInfo().DeclaredFields.Single(x => x.Name == "_queryCompilationContextFactory"); + private static readonly PropertyInfo DatabaseDependenciesField + = typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies"); public static string ToSql(this IQueryable query) where TEntity : class { if (!(query is EntityQueryable) && !(query is InternalDbSet)) + { throw new ArgumentException("Invalid query"); + } var queryCompiler = (IQueryCompiler)QueryCompilerField.GetValue(query.Provider); var nodeTypeProvider = (INodeTypeProvider)NodeTypeProviderField.GetValue(queryCompiler); var parser = (IQueryParser)CreateQueryParserMethod.Invoke(queryCompiler, new object[] { nodeTypeProvider }); var queryModel = parser.GetParsedQuery(query.Expression); var database = DataBaseField.GetValue(queryCompiler); - var queryCompilationContextFactory = (IQueryCompilationContextFactory)QueryCompilationContextFactoryField.GetValue(database); + var queryCompilationContextFactory = ((DatabaseDependencies)DatabaseDependenciesField.GetValue(database)).QueryCompilationContextFactory; var queryCompilationContext = queryCompilationContextFactory.Create(false); var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor(); modelVisitor.CreateQueryExecutor(queryModel); diff --git a/test/JsonApiDotNetCoreExampleTests/TestFixture.cs b/test/JsonApiDotNetCoreExampleTests/TestFixture.cs deleted file mode 100644 index 424163f956..0000000000 --- a/test/JsonApiDotNetCoreExampleTests/TestFixture.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Net.Http; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; - -namespace JsonApiDotNetCoreExampleTests -{ - public class TestFixture : IDisposable - where TStartup : class - { - private readonly TestServer _server; - private IServiceProvider _services; - - public TestFixture() - { - var builder = new WebHostBuilder() - .UseStartup(); - - _server = new TestServer(builder); - _services = _server.Host.Services; - Client = _server.CreateClient(); - } - - public HttpClient Client { get; set; } - - public T GetService() - { - return (T)_services.GetService(typeof(T)); - } - - private bool disposedValue = false; - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - Client.Dispose(); - _server.Dispose(); - } - - disposedValue = true; - } - } - - public void Dispose() - { - Dispose(true); - } - } -} \ No newline at end of file diff --git a/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs b/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs index 01b3ace217..43a89616df 100644 --- a/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs +++ b/test/JsonApiDotNetCoreExampleTests/WebHostCollection.cs @@ -1,4 +1,5 @@ using JsonApiDotNetCoreExample; +using JsonApiDotNetCoreExampleTests.Acceptance; using Xunit; namespace JsonApiDotNetCoreExampleTests diff --git a/test/JsonApiDotNetCoreExampleTests/appsettings.json b/test/JsonApiDotNetCoreExampleTests/appsettings.json index 7067b2bee0..7af3457293 100644 --- a/test/JsonApiDotNetCoreExampleTests/appsettings.json +++ b/test/JsonApiDotNetCoreExampleTests/appsettings.json @@ -6,7 +6,7 @@ "Logging": { "IncludeScopes": false, "LogLevel": { - "Default": "Debug", + "Default": "Error", "System": "Information", "Microsoft": "Information" } From dcc141acb7fccc306ddd07de339e457099e69914 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 5 Dec 2017 07:10:22 -0600 Subject: [PATCH 5/7] ci(travis): target 2.0.0 sdk --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 234e836e7e..b8a1d74643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ services: before_script: - psql -c 'create database JsonApiDotNetCoreExample;' -U postgres mono: none -dotnet: 1.0.4 # https://www.microsoft.com/net/download/linux +dotnet: 2.0.3 # https://www.microsoft.com/net/download/linux branches: only: - master From c02e09dbfc31b54974854d1f34a7a712ec0e9dc4 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 5 Dec 2017 07:25:04 -0600 Subject: [PATCH 6/7] ci: remove file watching on startup classes System.IO.IOException : The configured user limit (128) on the number of inotify instances has been reached. --- src/Examples/JsonApiDotNetCoreExample/Startup.cs | 2 +- src/Examples/NoEntityFrameworkExample/Startup.cs | 2 +- src/Examples/ReportsExample/Startup.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Examples/JsonApiDotNetCoreExample/Startup.cs b/src/Examples/JsonApiDotNetCoreExample/Startup.cs index 9683eb033d..1388004a55 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Startup.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Startup.cs @@ -18,7 +18,7 @@ public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); diff --git a/src/Examples/NoEntityFrameworkExample/Startup.cs b/src/Examples/NoEntityFrameworkExample/Startup.cs index fdea4fc582..81f743aa5f 100755 --- a/src/Examples/NoEntityFrameworkExample/Startup.cs +++ b/src/Examples/NoEntityFrameworkExample/Startup.cs @@ -18,7 +18,7 @@ public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); diff --git a/src/Examples/ReportsExample/Startup.cs b/src/Examples/ReportsExample/Startup.cs index 39d740da84..fed3707789 100644 --- a/src/Examples/ReportsExample/Startup.cs +++ b/src/Examples/ReportsExample/Startup.cs @@ -21,7 +21,7 @@ public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); From 947a079ad7c29454b4a6d80bff4ad957f0ddd30a Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 5 Dec 2017 17:25:27 -0600 Subject: [PATCH 7/7] chore(*): fix build warnings and use new Program.cs format --- .../JsonApiDotNetCoreExample.csproj | 4 ++-- .../JsonApiDotNetCoreExample/Program.cs | 18 +++++------------- .../NoEntityFrameworkExample/Program.cs | 14 ++++++-------- src/Examples/ReportsExample/Program.cs | 14 ++++++-------- .../CamelCasedModelsControllerTests.cs | 1 - .../Acceptance/TodoItemsControllerTests.cs | 10 +++++----- 6 files changed, 24 insertions(+), 37 deletions(-) diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index e9971a1113..dcbf2a2841 100755 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + $(NetCoreAppVersion) true JsonApiDotNetCoreExample Exe @@ -13,7 +13,7 @@ - + diff --git a/src/Examples/JsonApiDotNetCoreExample/Program.cs b/src/Examples/JsonApiDotNetCoreExample/Program.cs index 16f0ad10a1..e4e3fe355e 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Program.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Program.cs @@ -1,6 +1,5 @@ -using System.IO; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; namespace JsonApiDotNetCoreExample { @@ -8,19 +7,12 @@ public class Program { public static void Main(string[] args) { - var config = new ConfigurationBuilder() - .AddCommandLine(args) - .AddEnvironmentVariables(prefix: "ASPNETCORE_") - .Build(); + BuildWebHost(args).Run(); + } - var host = new WebHostBuilder() - .UseConfiguration(config) - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); - - host.Run(); - } } } diff --git a/src/Examples/NoEntityFrameworkExample/Program.cs b/src/Examples/NoEntityFrameworkExample/Program.cs index 5606e8e9f4..76f3020c52 100755 --- a/src/Examples/NoEntityFrameworkExample/Program.cs +++ b/src/Examples/NoEntityFrameworkExample/Program.cs @@ -1,4 +1,4 @@ -using System.IO; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace NoEntityFrameworkExample @@ -7,14 +7,12 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); - - host.Run(); - } } } diff --git a/src/Examples/ReportsExample/Program.cs b/src/Examples/ReportsExample/Program.cs index 41d4c37780..f3ce6c81b0 100644 --- a/src/Examples/ReportsExample/Program.cs +++ b/src/Examples/ReportsExample/Program.cs @@ -1,4 +1,4 @@ -using System.IO; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace ReportsExample @@ -7,14 +7,12 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); - - host.Run(); - } } } diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs index 3cc920544f..b76293adba 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs @@ -35,7 +35,6 @@ public CamelCasedModelsControllerTests(TestFixture fixture) [Fact] public async Task Can_Get_CamelCasedModels() - { // Arrange var model = _faker.Generate(); diff --git a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs index 3c4e748966..657e282cb8 100644 --- a/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs @@ -219,7 +219,7 @@ public async Task Can_Get_TodoItem_ById() Assert.Equal(todoItem.Description, deserializedBody.Description); Assert.Equal(todoItem.Ordinal, deserializedBody.Ordinal); Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G")); - Assert.Equal(null, deserializedBody.AchievedDate); + Assert.Null(deserializedBody.AchievedDate); } [Fact] @@ -248,7 +248,7 @@ public async Task Can_Get_TodoItem_WithOwner() Assert.Equal(todoItem.Description, deserializedBody.Description); Assert.Equal(todoItem.Ordinal, deserializedBody.Ordinal); Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G")); - Assert.Equal(null, deserializedBody.AchievedDate); + Assert.Null(deserializedBody.AchievedDate); } [Fact] @@ -301,7 +301,7 @@ public async Task Can_Post_TodoItem() Assert.Equal(HttpStatusCode.Created, response.StatusCode); Assert.Equal(todoItem.Description, deserializedBody.Description); Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G")); - Assert.Equal(null, deserializedBody.AchievedDate); + Assert.Null(deserializedBody.AchievedDate); } [Fact] @@ -350,7 +350,7 @@ public async Task Can_Patch_TodoItem() Assert.Equal(newTodoItem.Description, deserializedBody.Description); Assert.Equal(newTodoItem.Ordinal, deserializedBody.Ordinal); Assert.Equal(newTodoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G")); - Assert.Equal(null, deserializedBody.AchievedDate); + Assert.Null(deserializedBody.AchievedDate); } [Fact] @@ -453,7 +453,7 @@ public async Task Can_Patch_TodoItemWithNullValue() Assert.Equal(newTodoItem.Description, deserializedBody.Description); Assert.Equal(newTodoItem.Ordinal, deserializedBody.Ordinal); Assert.Equal(newTodoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G")); - Assert.Equal(null, deserializedBody.AchievedDate); + Assert.Null(deserializedBody.AchievedDate); } [Fact]