Skip to content

Commit 148b376

Browse files
fix: update ChatAvailabilityTests to use IntegrationTestBase pattern
Migrate ChatAvailabilityTests from the old [ClassDataSource<WebApplicationFactory>] pattern to the new IntegrationTestBase base class introduced by PR #1100. - Inherit from IntegrationTestBase instead of using ClassDataSource attribute - Use McpTestHelper.CreateClient(Factory) instead of factory.CreateClient(...) - Use this.Factory (TracedWebApplicationFactory<Program>) via inherited property - Remove unused WebApplicationFactoryClientOptions import
1 parent e69f533 commit 148b376

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

EssentialCSharp.Web.Tests/ChatAvailabilityTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
using System.Net;
22
using System.Net.Http.Json;
33
using System.Text.Json;
4-
using Microsoft.AspNetCore.Mvc.Testing;
54

65
namespace EssentialCSharp.Web.Tests;
76

87
[NotInParallel("ChatAvailabilityTests")]
9-
[ClassDataSource<WebApplicationFactory>(Shared = SharedType.PerClass)]
10-
public class ChatAvailabilityTests(WebApplicationFactory factory)
8+
public class ChatAvailabilityTests : IntegrationTestBase
119
{
1210
private const string HCaptchaTestToken = "10000000-aaaa-bbbb-cccc-000000000001";
1311

1412
[Test]
1513
public async Task ChatMessage_WhenBackendUnavailable_Returns503WithContract()
1614
{
17-
HttpClient client = factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
15+
HttpClient client = McpTestHelper.CreateClient(Factory);
1816

19-
string userId = await McpTestHelper.CreateUserAsync(factory, "chat-unavailable");
20-
(string cookieName, string cookieValue) = await McpTestHelper.CreateIdentityApplicationCookieAsync(factory, userId);
17+
string userId = await McpTestHelper.CreateUserAsync(Factory, "chat-unavailable");
18+
(string cookieName, string cookieValue) = await McpTestHelper.CreateIdentityApplicationCookieAsync(Factory, userId);
2119

2220
using var request = new HttpRequestMessage(HttpMethod.Post, "/api/chat/message")
2321
{
@@ -35,10 +33,10 @@ public async Task ChatMessage_WhenBackendUnavailable_Returns503WithContract()
3533
[Test]
3634
public async Task ChatStream_WhenBackendUnavailable_Returns503WithContract()
3735
{
38-
HttpClient client = factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
36+
HttpClient client = McpTestHelper.CreateClient(Factory);
3937

40-
string userId = await McpTestHelper.CreateUserAsync(factory, "chat-stream-unavailable");
41-
(string cookieName, string cookieValue) = await McpTestHelper.CreateIdentityApplicationCookieAsync(factory, userId);
38+
string userId = await McpTestHelper.CreateUserAsync(Factory, "chat-stream-unavailable");
39+
(string cookieName, string cookieValue) = await McpTestHelper.CreateIdentityApplicationCookieAsync(Factory, userId);
4240

4341
using var request = new HttpRequestMessage(HttpMethod.Post, "/api/chat/stream")
4442
{

0 commit comments

Comments
 (0)