45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace RpgRoller.Tests;
|
|
|
|
public sealed class FrontendHostTests : ApiTestBase
|
|
{
|
|
public FrontendHostTests(WebApplicationFactory<Program> factory) : base(factory)
|
|
{
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RootPath_ServesBlazorFrontendShell()
|
|
{
|
|
using var factory = CreateFactory(1);
|
|
using var client = factory.CreateClient(new() { AllowAutoRedirect = false });
|
|
var response = await client.GetAsync("/");
|
|
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
var html = await response.Content.ReadAsStringAsync();
|
|
Assert.Contains("_framework/blazor.web.js", html);
|
|
Assert.Contains("Connecting...", html);
|
|
}
|
|
|
|
[Fact]
|
|
public void BlazorHub_AllowsLargerInteropPayloads()
|
|
{
|
|
using var factory = CreateFactory();
|
|
var componentHubType = Type.GetType("Microsoft.AspNetCore.Components.Server.ComponentHub, Microsoft.AspNetCore.Components.Server");
|
|
Assert.NotNull(componentHubType);
|
|
|
|
var hubOptionsType = typeof(HubOptions<>).MakeGenericType(componentHubType);
|
|
var optionsType = typeof(IOptions<>).MakeGenericType(hubOptionsType);
|
|
var options = factory.Services.GetService(optionsType);
|
|
Assert.NotNull(options);
|
|
|
|
var value = optionsType.GetProperty("Value")!.GetValue(options);
|
|
Assert.NotNull(value);
|
|
|
|
var maximumReceiveMessageSize = (long?)hubOptionsType.GetProperty("MaximumReceiveMessageSize")!.GetValue(value);
|
|
|
|
Assert.Equal(256 * 1024, maximumReceiveMessageSize);
|
|
}
|
|
}
|