You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
1 year ago
|
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()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|