Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made WebApplicationFactory disposal silent #25

Merged
merged 1 commit into from
May 24, 2024
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
19 changes: 17 additions & 2 deletions src/Ogooreck/API/ApiSpecification.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

#pragma warning disable CS1591

Expand Down Expand Up @@ -26,6 +28,10 @@ protected ApiSpecification(WebApplicationFactory<TProgram> applicationFactory)
public static ApiSpecification<TProgram> Setup(WebApplicationFactory<TProgram> applicationFactory) =>
new(applicationFactory);

public static ApiSpecification<TProgram> With(ILoggerProvider loggerProvider) =>
new(new WebApplicationFactory<TProgram>().WithWebHostBuilder(
b => b.ConfigureServices(s => s.AddSingleton(loggerProvider))));

public GivenApiSpecificationBuilder Given(
params RequestDefinition[] builders
) =>
Expand Down Expand Up @@ -70,8 +76,17 @@ public async Task<HttpResponseMessage> Scenario(
return response;
}

public void Dispose() =>
applicationFactory.Dispose();
public void Dispose()
{
try
{
applicationFactory.Dispose();
}
catch (Exception exc)
{
Console.WriteLine($"Error disposing WebApplicationFactory: {exc}");
}
}
}

public class TestApiRequest
Expand Down
2 changes: 1 addition & 1 deletion src/Ogooreck/Ogooreck.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>0.8.1</VersionPrefix>
<VersionPrefix>0.8.2</VersionPrefix>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GenerateAssemblyTitleAttribute>true</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>true</GenerateAssemblyDescriptionAttribute>
Expand Down
Loading