Increase Blazor hub message limit
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace RpgRoller.Tests;
|
namespace RpgRoller.Tests;
|
||||||
|
|
||||||
public sealed class FrontendHostTests : ApiTestBase
|
public sealed class FrontendHostTests : ApiTestBase
|
||||||
@@ -18,4 +21,24 @@ public sealed class FrontendHostTests : ApiTestBase
|
|||||||
Assert.Contains("_framework/blazor.web.js", html);
|
Assert.Contains("_framework/blazor.web.js", html);
|
||||||
Assert.Contains("Connecting...", 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ using RpgRoller.Hosting;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddRpgRollerCore(builder.Configuration, builder.Environment);
|
builder.Services.AddRpgRollerCore(builder.Configuration, builder.Environment);
|
||||||
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
|
builder.Services.AddRazorComponents()
|
||||||
|
.AddInteractiveServerComponents()
|
||||||
|
.AddHubOptions(options => options.MaximumReceiveMessageSize = 256 * 1024);
|
||||||
builder.Services.AddScoped<RpgRollerApiClient>();
|
builder.Services.AddScoped<RpgRollerApiClient>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|||||||
Reference in New Issue
Block a user