34 lines
786 B
C#
34 lines
786 B
C#
using System.Net.Http.Headers;
|
|
using System.Net.Http.Json;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Xunit;
|
|
using TestAspNetCore.Infra;
|
|
|
|
[assembly: AssemblyFixture(typeof(TestAspNetCore.TestFixture))]
|
|
|
|
namespace TestAspNetCore;
|
|
|
|
public class TestFixture : IAsyncLifetime
|
|
{
|
|
public HttpClient Client { get; private set; } = null!;
|
|
private readonly WebApplicationFactory<Program> factory;
|
|
|
|
public TestFixture()
|
|
{
|
|
factory = new WebApplicationFactory<Program>();
|
|
}
|
|
|
|
public async ValueTask InitializeAsync()
|
|
{
|
|
Client = factory.CreateClient();
|
|
}
|
|
|
|
public ValueTask DisposeAsync()
|
|
{
|
|
Client.Dispose();
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
}
|