This commit is contained in:
commit
0e79a8eb5e
1 changed files with 1282 additions and 0 deletions
34
tests/TestFixture.cs
Normal file
34
tests/TestFixture.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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 TestWeb.Infra;
|
||||
|
||||
[assembly: AssemblyFixture(typeof(TestWeb.Tests.TestFixture))]
|
||||
|
||||
namespace TestWeb.Tests;
|
||||
|
||||
public class TestFixture : IAsyncLifetime
|
||||
{
|
||||
public HttpClient Client { get; private set; } = null!;
|
||||
private readonly WebApplicationFactory<Program> factory;
|
||||
|
||||
public TestFixture()
|
||||
{
|
||||
factory = new WebApplicationFactory<Program>();
|
||||
}
|
||||
|
||||
public ValueTask InitializeAsync()
|
||||
{
|
||||
Client = factory.CreateClient();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Client.Dispose();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue