项目结构更新
parent
104938af98
commit
6d9caceeaa
@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
|
||||
using Xunit.Abstractions;
|
||||
|
||||
using XUnitDIStudy.Model;
|
||||
|
||||
namespace XUnitDIStudy.IntegrationTest
|
||||
{
|
||||
|
||||
public class BasicTest:IDisposable,IClassFixture<WebApplicationFactory<XUnitDIStudy.WebApp.Program>>
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
private readonly WebApplicationFactory<WebApp.Program> _factory;
|
||||
|
||||
public BasicTest(ITestOutputHelper outputHelper,WebApplicationFactory<WebApp.Program> factory)
|
||||
{
|
||||
_output = outputHelper;
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact,Custom]
|
||||
public async void Client_Test()
|
||||
{
|
||||
var httpClient = _factory.CreateClient();
|
||||
|
||||
var respone = await httpClient.GetAsync("Default/GetAll");
|
||||
|
||||
respone.EnsureSuccessStatusCode();
|
||||
|
||||
var students = await respone.Content.ReadFromJsonAsync<List<Student>>();
|
||||
|
||||
Assert.NotNull(students);
|
||||
Assert.NotEmpty(students);
|
||||
Assert.True(students.Count>0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"XUnitDIStudy.IntegrationTest": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53390;http://localhost:53391"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace XUnitDIStudy.IntegrationTest
|
||||
{
|
||||
|
||||
public class UseXUnit:IDisposable
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
public UseXUnit(ITestOutputHelper outputHelper)
|
||||
{
|
||||
_output = outputHelper;
|
||||
}
|
||||
|
||||
[Fact,Custom]
|
||||
public void UseXunit_Test()
|
||||
{
|
||||
_output.WriteLine("使用 xUnit 单元测试框架!");
|
||||
|
||||
Assert.True(true,"使用 xUnit 单元测试框架!");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngleSharp" Version="1.1.2" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageReference Include="xunit" Version="2.7.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XUnitDIStudy.WebApp\XUnitDIStudy.WebApp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue