ExampleSignalR/TestProject/UnitTest1.cs

38 lines
833 B
C#
Raw Normal View History

2024-11-12 18:02:09 +05:00
using Microsoft.AspNetCore.SignalR.Client;
using static System.Net.WebRequestMethods;
using static Microsoft.AspNetCore.Http.StatusCodes;
namespace ExampleSignalR.Test;
public class UnitTest1 : BaseIntegrationTest
{
private readonly HttpClient _httpClient;
public UnitTest1(WebAppFactoryFixture factory) : base(factory)
{
_httpClient = factory.CreateClient();
}
[Fact]
public async void ConnectToSignalRHub()
{
var hubConnection = new HubConnectionBuilder()
.WithUrl($"{factory.url}/chatHub") // ...appsettings.json
.Build();
await hubConnection.StartAsync();
}
//public async Task Connect()
//{
// try
// {
// await hubConnection.StartAsync();
// Console.WriteLine("<22><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
// }
// catch (Exception ex)
// {
// Console.WriteLine($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {ex.Message}");
// }
//}
}