- **TestSetup.cs** - Updated `CreateTestConfig` method to initialize `Config` with required properties using object initializer syntax. - **ProxyIntegrationTests.cs** - Added null checks for `mockServer.Urls` before accessing it to prevent potential null reference exceptions. - Improved error handling for mock server URL access. - **VRChatAuthenticationTests.cs** - Added null checks for `mockServer.Urls` before accessing it to prevent potential null reference exceptions. - Enhanced the mock server setup to include null checks for request body content. - **Config.cs** - Added the `required` modifier to non-nullable properties in `ConfigAccount` and `iConfig` classes. - Updated the `Load` method to initialize the `Config` instance with required properties using object initializer syntax. - **Program.cs** - Added a null check for `result.CloseStatus` in WebSocket handling to prevent potential null reference exceptions.
45 lines
No EOL
1.2 KiB
C#
45 lines
No EOL
1.2 KiB
C#
using System.Net;
|
|
using WireMock.Server;
|
|
|
|
namespace VRCAuthProxy.Tests.Helpers
|
|
{
|
|
public class TestSetup : IDisposable
|
|
{
|
|
public WireMockServer MockVRChatApi { get; private set; }
|
|
|
|
public TestSetup()
|
|
{
|
|
// Start WireMock server to mock VRChat API
|
|
MockVRChatApi = WireMockServer.Start();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
MockVRChatApi?.Dispose();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a test configuration with mock accounts
|
|
/// </summary>
|
|
public static Config CreateTestConfig()
|
|
{
|
|
return new Config
|
|
{
|
|
Accounts = new List<ConfigAccount>
|
|
{
|
|
new ConfigAccount
|
|
{
|
|
username = "testuser1",
|
|
password = "testpassword1",
|
|
totpSecret = "TESTSECRET1"
|
|
},
|
|
new ConfigAccount
|
|
{
|
|
username = "testuser2",
|
|
password = "testpassword2"
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
} |