Last active
August 28, 2020 13:57
-
-
Save flashlin/22b36afc62bba5598795dd59eff67e30 to your computer and use it in GitHub Desktop.
System Under Test (SUT) Integration Test for dotnet core 3 #test #aspnetcore3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BasicSystemUnderTest<TStartup> : IClassFixture<WebApplicationFactory<TStartup>> | |
where TStartup : class | |
{ | |
protected readonly WebApplicationFactory<TStartup> _factory; | |
public BasicSystemUnderTest(WebApplicationFactory<TStartup> factory) | |
{ | |
_factory = factory; | |
} | |
public async Task Test1() | |
{ | |
var client = _factory | |
.CreateClient(); | |
var response = await client.GetAsync("/Home/Hello"); | |
//response.EnsureSuccessStatusCode(); // Status Code 200-299 | |
var content = await response.Content.ReadAsStringAsync(); | |
Assert.Equal("text/plain; charset=utf-8", response.Content.Headers.ContentType.ToString()); | |
Assert.Equal("Hello Razor", content); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment