Created
March 25, 2021 10:02
-
-
Save lawrence-laz/1f86738c7e2b4820768f39b76ed4ec4c to your computer and use it in GitHub Desktop.
Hosting a test application for automated integration tests.
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
[Theory] | |
[InlineData("Development")] | |
public async Task CallSwaggerEndpoint_ShouldReturnHttpOk(string environment) | |
{ | |
// Arrange | |
using var sut = await Program.CreateHostBuilder(null) | |
.UseEnvironment(environment) | |
.UseDefaultServiceProvider((context, options) => | |
{ | |
options.ValidateScopes = true; | |
options.ValidateOnBuild = true; | |
}) | |
.ConfigureWebHost(webBuilder => | |
{ | |
webBuilder.UseTestServer(); | |
}) | |
.StartAsync(); | |
var client = sut.GetTestServer().CreateClient(); | |
// Act | |
var response = await client.GetAsync($"/swagger/v1/swagger.json"); | |
// Assert | |
response.StatusCode.Should().Be(HttpStatusCode.OK); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment