1
1
using System . Net ;
2
- using System . Threading . Tasks ;
3
2
using Microsoft . AspNetCore . Hosting ;
3
+ using Microsoft . AspNetCore . Http ;
4
4
using Microsoft . AspNetCore . Mvc . Testing ;
5
5
using Microsoft . AspNetCore . TestHost ;
6
6
using Microsoft . Extensions . DependencyInjection ;
7
+ using Microsoft . Extensions . Logging ;
7
8
using Microsoft . VisualStudio . TestTools . UnitTesting ;
8
9
9
10
namespace MyWebApp . IntegrationTests
@@ -16,7 +17,7 @@ public async Task HttpRequestWithAllowedIpAddressShouldReturn200()
16
17
{
17
18
var factory = new WebApplicationFactory < Startup > ( ) . WithWebHostBuilder ( builder =>
18
19
{
19
- builder . UseSetting ( "https_port" , "5001" ) ;
20
+ builder . UseSetting ( "https_port" , "5001" ) . ConfigureLogging ( c => c . AddConsole ( ) ) ;
20
21
builder . ConfigureTestServices ( services =>
21
22
{
22
23
services . AddSingleton < IStartupFilter > ( new CustomRemoteIpStartupFilter ( IPAddress . Parse ( "127.0.0.1" ) ) ) ;
@@ -37,7 +38,7 @@ public async Task HttpRequestWithForbiddenIpAddressShouldReturn403()
37
38
{
38
39
var factory = new WebApplicationFactory < Startup > ( ) . WithWebHostBuilder ( builder =>
39
40
{
40
- builder . UseSetting ( "https_port" , "5001" ) ;
41
+ builder . UseSetting ( "https_port" , "5001" ) . ConfigureLogging ( c => c . AddConsole ( ) ) ;
41
42
builder . ConfigureTestServices ( services =>
42
43
{
43
44
services . AddSingleton < IStartupFilter > ( new CustomRemoteIpStartupFilter ( IPAddress . Parse ( "127.168.1.32" ) ) ) ;
@@ -54,7 +55,7 @@ public async Task HttpRequestWithForbiddenIpAddressShouldReturn403()
54
55
public async Task HttpRequestWithLocalHostIpAddressShouldReturn200 ( )
55
56
{
56
57
var factory = new WebApplicationFactory < Startup > ( )
57
- . WithWebHostBuilder ( builder => builder . UseSetting ( "https_port" , "5001" ) ) ;
58
+ . WithWebHostBuilder ( builder => builder . UseSetting ( "https_port" , "5001" ) . ConfigureLogging ( c => c . AddConsole ( ) ) ) ;
58
59
var client = factory . CreateClient ( new WebApplicationFactoryClientOptions
59
60
{
60
61
AllowAutoRedirect = true
0 commit comments