Skip to content

Commit d6f407a

Browse files
committed
Added a test to validate generic HttpClient setup works.
1 parent 12fe8a4 commit d6f407a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Mvc/test/Mvc.FunctionalTests/RealServerBackedIntegrationTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Net;
5+
using System.Net.Http;
56
using System.Net.Http.Headers;
67

78
namespace Microsoft.AspNetCore.Mvc.FunctionalTests;
@@ -37,4 +38,20 @@ public async Task RetrievesDataFromRealServer()
3738
Assert.Contains("wall", responseContent);
3839
Assert.Contains("floor", responseContent);
3940
}
41+
42+
[Fact]
43+
public async Task ServerReachableViaGenericHttpClient()
44+
{
45+
// Arrange
46+
var baseAddress = new Uri("http://localhost:5000");
47+
48+
// Act
49+
using var factoryClient = Factory.CreateClient();
50+
using var client = new HttpClient() { BaseAddress = factoryClient.BaseAddress };
51+
52+
using var response = await client.GetAsync("/");
53+
54+
// Assert
55+
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
56+
}
4057
}

0 commit comments

Comments
 (0)