diff --git a/Build.ps1 b/Build.ps1 index 60006411a8..7cdc82e3d9 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -22,23 +22,26 @@ $revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BU $revision = "{0:D4}" -f [convert]::ToInt32($revision, 10) dotnet restore +CheckLastExitCode -dotnet build ./src/Examples/GettingStarted/GettingStarted.csproj +dotnet build -c Release CheckLastExitCode -dotnet test ./test/UnitTests/UnitTests.csproj +# Workaround: running 'dotnet test -c Release' fails for yet unknown reasons on AppVeyor, so we run tests one by one. + +dotnet test ./test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj -c Release --no-build CheckLastExitCode -dotnet test ./test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj +dotnet test ./test/DiscoveryTests/DiscoveryTests.csproj -c Release --no-build CheckLastExitCode -dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +dotnet test ./test/IntegrationTests/IntegrationTests.csproj -c Release --no-build CheckLastExitCode -dotnet test ./test/DiscoveryTests/DiscoveryTests.csproj +dotnet test ./test/UnitTests/UnitTests.csproj -c Release --no-build CheckLastExitCode -dotnet build ./src/JsonApiDotNetCore/JsonApiDotNetCore.csproj -c Release +dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj -c Release --no-build CheckLastExitCode Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG" diff --git a/build.sh b/build.sh index 71989c80a7..1edc2ea9a4 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,5 @@ set -e dotnet restore - -dotnet test ./test/UnitTests/UnitTests.csproj -dotnet test ./test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj -dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +dotnet build -c Release +dotnet test -c Release --no-build diff --git a/src/Examples/NoEntityFrameworkExample/Startup.cs b/src/Examples/NoEntityFrameworkExample/Startup.cs index f21f59c7ba..8f27ed1d7f 100644 --- a/src/Examples/NoEntityFrameworkExample/Startup.cs +++ b/src/Examples/NoEntityFrameworkExample/Startup.cs @@ -1,3 +1,4 @@ +using System; using JsonApiDotNetCore.Extensions; using JsonApiDotNetCore.Services; using Microsoft.AspNetCore.Builder; @@ -42,7 +43,7 @@ public virtual void ConfigureServices(IServiceCollection services) ); services.AddScoped, TodoItemService>(); var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseNpgsql(GetDbConnectionString()); + optionsBuilder.UseNpgsql(GetDbConnectionString(), options => options.SetPostgresVersion(new Version(9,6))); services.AddSingleton(Configuration); services.AddSingleton(optionsBuilder.Options); services.AddScoped(); diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.sln b/src/JsonApiDotNetCore/JsonApiDotNetCore.sln deleted file mode 100644 index 58b08eb568..0000000000 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCore", "JsonApiDotNetCore.csproj", "{C8E2AE2E-80E2-408E-89FF-F66BA720F879}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|Any CPU = Release|Any CPU - Debug|Any CPU = Debug|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C8E2AE2E-80E2-408E-89FF-F66BA720F879}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C8E2AE2E-80E2-408E-89FF-F66BA720F879}.Release|Any CPU.Build.0 = Release|Any CPU - {C8E2AE2E-80E2-408E-89FF-F66BA720F879}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8E2AE2E-80E2-408E-89FF-F66BA720F879}.Debug|Any CPU.Build.0 = Debug|Any CPU - EndGlobalSection -EndGlobal diff --git a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln b/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln deleted file mode 100644 index 87d08fd486..0000000000 --- a/test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.sln +++ /dev/null @@ -1,17 +0,0 @@ - -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/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index 548cb6b048..5b652cb098 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -15,7 +15,6 @@ - diff --git a/test/NoEntityFrameworkTests/TestScopedServiceProvider.cs b/test/NoEntityFrameworkTests/TestScopedServiceProvider.cs new file mode 100644 index 0000000000..69628ff8f1 --- /dev/null +++ b/test/NoEntityFrameworkTests/TestScopedServiceProvider.cs @@ -0,0 +1,28 @@ +using System; +using JsonApiDotNetCore.Services; +using Microsoft.AspNetCore.Http; +using Moq; + +namespace NoEntityFrameworkTests +{ + public class TestScopedServiceProvider : IScopedServiceProvider + { + private readonly IServiceProvider _serviceProvider; + private Mock _httpContextAccessorMock = new Mock(); + + public TestScopedServiceProvider(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public object GetService(Type serviceType) + { + if (serviceType == typeof(IHttpContextAccessor)) + { + return _httpContextAccessorMock.Object; + } + + return _serviceProvider.GetService(serviceType); + } + } +} diff --git a/test/NoEntityFrameworkTests/TestStartup.cs b/test/NoEntityFrameworkTests/TestStartup.cs index 3f0cd1fc4c..ad0022a197 100644 --- a/test/NoEntityFrameworkTests/TestStartup.cs +++ b/test/NoEntityFrameworkTests/TestStartup.cs @@ -2,8 +2,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using NoEntityFrameworkExample; -using System; -using UnitTests; namespace NoEntityFrameworkTests {