Browse Source

More tests.

pull/349/head
Sebastian Stehle 7 years ago
parent
commit
98a93e9ba7
  1. 2
      Dockerfile
  2. 2
      Dockerfile.build
  3. 6
      src/Squidex.Web/SquidexWeb.cs
  4. 4
      tests/RunCoverage.ps1
  5. 75
      tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs

2
Dockerfile

@ -24,7 +24,7 @@ RUN dotnet restore \
&& dotnet test tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj \ && dotnet test tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj \
&& dotnet test tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj \ && dotnet test tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj \
&& dotnet test tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj \ && dotnet test tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj \
&& dotnet test tests/Squidex.Tests/Squidex.Tests.csproj && dotnet test tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj
# Publish # Publish
RUN dotnet publish src/Squidex/Squidex.csproj --output /out/alpine --configuration Release -r alpine.3.7-x64 RUN dotnet publish src/Squidex/Squidex.csproj --output /out/alpine --configuration Release -r alpine.3.7-x64

2
Dockerfile.build

@ -21,7 +21,7 @@ RUN dotnet restore \
&& dotnet test tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj \ && dotnet test tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj \
&& dotnet test tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj \ && dotnet test tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj \
&& dotnet test tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj \ && dotnet test tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj \
&& dotnet test tests/Squidex.Tests/Squidex.Tests.csproj && dotnet test tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj
# Publish # Publish
RUN dotnet publish src/Squidex/Squidex.csproj --output /out/ --configuration Release RUN dotnet publish src/Squidex/Squidex.csproj --output /out/ --configuration Release

6
src/Squidex.Web/SquidexWeb.cs

@ -9,10 +9,10 @@ using System.Reflection;
#pragma warning disable RECS0014 // If all fields, properties and methods members are static, the class can be made static. #pragma warning disable RECS0014 // If all fields, properties and methods members are static, the class can be made static.
namespace Squidex.Infrastructure namespace Squidex.Web
{ {
public sealed class SquidexInfrastructure public sealed class SquidexWeb
{ {
public static readonly Assembly Assembly = typeof(SquidexInfrastructure).Assembly; public static readonly Assembly Assembly = typeof(SquidexWeb).Assembly;
} }
} }

4
tests/RunCoverage.ps1

@ -69,8 +69,8 @@ if ($all -Or $web) {
&"$folderHome\.nuget\packages\OpenCover\4.7.922\tools\OpenCover.Console.exe" ` &"$folderHome\.nuget\packages\OpenCover\4.7.922\tools\OpenCover.Console.exe" `
-register:user ` -register:user `
-target:"C:\Program Files\dotnet\dotnet.exe" ` -target:"C:\Program Files\dotnet\dotnet.exe" `
-targetargs:"test $folderWorking\Squidex.Tests\Squidex.Tests.csproj" ` -targetargs:"test $folderWorking\Squidex.Web.Tests\Squidex.Web.Tests.csproj" `
-filter:"+[Squidex]Squidex.Pipeline*" ` -filter:"+[Squidex]Squidex.Web*" `
-skipautoprops ` -skipautoprops `
-output:"$folderWorking\$folderReports\Web.xml" ` -output:"$folderWorking\$folderReports\Web.xml" `
-oldStyle -oldStyle

75
tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs

@ -0,0 +1,75 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Squidex.Infrastructure.Tasks;
using Xunit;
namespace Squidex.Web.Pipeline
{
public class CleanupHostMiddlewareTests
{
private readonly RequestDelegate next;
private readonly CleanupHostMiddleware sut;
private bool isNextCalled;
public CleanupHostMiddlewareTests()
{
next = context =>
{
isNextCalled = true;
return TaskHelper.Done;
};
sut = new CleanupHostMiddleware(next);
}
[Fact]
public async Task Should_cleanup_host_if_https_schema_contains_default_port()
{
var httpContext = new DefaultHttpContext();
httpContext.Request.Scheme = "https";
httpContext.Request.Host = new HostString("host", 443);
await sut.Invoke(httpContext);
Assert.Null(httpContext.Request.Host.Port);
Assert.True(isNextCalled);
}
[Fact]
public async Task Should_cleanup_host_if_http_schema_contains_default_port()
{
var httpContext = new DefaultHttpContext();
httpContext.Request.Scheme = "http";
httpContext.Request.Host = new HostString("host", 80);
await sut.Invoke(httpContext);
Assert.Null(httpContext.Request.Host.Port);
Assert.True(isNextCalled);
}
[Fact]
public async Task Should_not_cleanup_host_if_http_schema_contains_other_port()
{
var httpContext = new DefaultHttpContext();
httpContext.Request.Scheme = "http";
httpContext.Request.Host = new HostString("host", 8080);
await sut.Invoke(httpContext);
Assert.Equal(8080, httpContext.Request.Host.Port);
Assert.True(isNextCalled);
}
}
}
Loading…
Cancel
Save