Initial commit
All checks were successful
Build / build (push) Successful in 57s

This commit is contained in:
2025-11-08 14:26:53 +00:00
commit 018d8e184e
26 changed files with 1251 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.v3" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\TestAspNetCore.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\src\**\*.Test.cs" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,33 @@
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;
}
}