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.
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Mvc.Testing;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
using Xunit.Extensions;
|
|
using Xunit.Sdk;
|
|
|
|
using XUnitDIStudy.Model;
|
|
|
|
namespace XUnitDIStudy.Test.IntegrationTest
|
|
{
|
|
[Collection(TestConst.IntegrationCollectionDefinitionKey)]
|
|
public class DefaultWebApplicationFactoryTest
|
|
{
|
|
private readonly WebApplicationFactory<WebApp.Startup> _factory;
|
|
public DefaultWebApplicationFactoryTest(WebApplicationFactory<WebApp.Startup> factory)
|
|
{
|
|
_factory = factory;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task TestAsync()
|
|
{
|
|
// Arrange
|
|
var client = _factory.CreateClient();
|
|
|
|
// Act
|
|
var response = await client.GetAsync("/Default/GetAll");
|
|
|
|
// Assert
|
|
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
|
|
|
List<Student> result = System.Text.Json.JsonSerializer.Deserialize<List<Student>>(response.Content.ReadAsStringAsync().Result);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.True(result.Count > 0);
|
|
}
|
|
}
|
|
}
|