Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<NoWarn>S125;CA1848;CA1002;CA1515;S1118</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('Tests'))">
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
<TestingPlatformCaptureOutput>true</TestingPlatformCaptureOutput>
<UseMicrosoftTestingPlatformRunner>false</UseMicrosoftTestingPlatformRunner>
<TestingPlatformDotnetTestSupport>false</TestingPlatformDotnetTestSupport>
<TestingPlatformShowTestsFailure>false</TestingPlatformShowTestsFailure>
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
<NoWarn>$(NoWarn);CA5394;CA1707</NoWarn>
</PropertyGroup>
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion tests/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.0.4" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="Serilog.Sinks.XUnit3" Version="1.1.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
<PackageVersion Include="Testcontainers" Version="4.7.0" />
<PackageVersion Include="xunit.v3" Version="3.1.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion tests/IntegrationTests/ApiEndpointsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace IntegrationTests;

public sealed class ApiEndpointsTests(Fixture fixture) : IntegrationTestBase(fixture)
public sealed class ApiEndpointsTests(Fixture fixture, ITestOutputHelper outputHelper) : IntegrationTestBase(fixture, outputHelper)
{
private const string DateFormat = "yyyy-MM-dd";
private const string BaseUrl = "/api/v1";
Expand Down
1 change: 1 addition & 0 deletions tests/IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Serilog.Sinks.XUnit3" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Testcontainers" />
<PackageReference Include="xunit.v3" />
Expand Down
16 changes: 0 additions & 16 deletions tests/IntegrationTests/Setup/ApplicationFactory.cs

This file was deleted.

7 changes: 4 additions & 3 deletions tests/IntegrationTests/Setup/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ namespace IntegrationTests.Setup;

public abstract class IntegrationTestBase : IAsyncLifetime
{
internal readonly ApplicationFactory _factory;
internal readonly TestApplicationFactory _factory;
internal readonly HttpClient _client;

protected IntegrationTestBase(Fixture fixture)
protected IntegrationTestBase(Fixture fixture, ITestOutputHelper outputHelper)
{
_factory = new ApplicationFactory(fixture);
_factory = new TestApplicationFactory(fixture);
_factory.SetTestOutputHelper(outputHelper);
_client = _factory.CreateClient();
}

Expand Down
43 changes: 43 additions & 0 deletions tests/IntegrationTests/Setup/TestApplicationFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Serilog;
using Serilog.Sinks.XUnit3;
using Xunit;

namespace IntegrationTests.Setup;

public sealed class TestApplicationFactory(Fixture fixture) : WebApplicationFactory<Program>
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
if (EnvVarAccessors.UseMocking)
{
builder?.UseSetting(EnvVarKeys.MarketClientUrl, $"http://localhost:{fixture.GetPort()}");
}
}

protected override IHost CreateHost(IHostBuilder builder)
{
builder.ConfigureServices(services =>
{
services.AddSingleton(Options.Create(new XUnit3TestOutputSinkOptions()));
services.AddSingleton<XUnit3TestOutputSink>();
});

builder.UseSerilog((ctx, sp, config) =>
config.MinimumLevel.Information()
.MinimumLevel.Override("System", Serilog.Events.LogEventLevel.Error)
.MinimumLevel.Override("Microsoft.AspNetCore", Serilog.Events.LogEventLevel.Error)
.WriteTo.XUnit3TestOutput(sp.GetRequiredService<XUnit3TestOutputSink>())
);

return base.CreateHost(builder);
}

public void SetTestOutputHelper(ITestOutputHelper testOutputHelper) =>
Services.GetRequiredService<XUnit3TestOutputSink>().TestOutputHelper = testOutputHelper;
}
11 changes: 11 additions & 0 deletions tests/IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
"Microsoft.Testing.Platform": "1.8.4"
}
},
"Serilog.Sinks.XUnit3": {
"type": "Direct",
"requested": "[1.1.0, )",
"resolved": "1.1.0",
"contentHash": "XqGy76yqRh9pj4FGqpjDlU8fjuw7QnXrYOuBNaLgtyvBn+/ALtCQqyiG6AqYByHkynCzkz1Dx383P1OHyyTg/Q==",
"dependencies": {
"Microsoft.Extensions.Options": "9.0.9",
"Serilog": "4.3.0",
"xunit.v3.extensibility.core": "3.0.1"
}
},
"Shouldly": {
"type": "Direct",
"requested": "[4.3.0, )",
Expand Down
Loading