Initial commit

This commit is contained in:
BillyCool
2026-04-21 01:10:25 +10:00
commit c5595ea083
1752 changed files with 45767 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using MariesWonderland.Data;
using MariesWonderland.Interceptors;
using MariesWonderland.Proto.User;
using MariesWonderland.Tests.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace MariesWonderland.Tests.Interceptors;
public class AutoSaveInterceptorTests : InterceptorTestBase
{
private static readonly ILogger<AutoSaveInterceptor> Logger = NullLogger<AutoSaveInterceptor>.Instance;
private static AutoSaveInterceptor CreateInterceptor(UserDataStore store) =>
new(store, Logger);
/// <summary>
/// Verifies that the interceptor returns the continuation's response unchanged.
/// </summary>
[Fact]
public async Task ContinuationResultIsReturned()
{
var store = CreateEmptyStore();
var interceptor = CreateInterceptor(store);
var context = FakeServerCallContext.For(userId: 1);
var expected = new SetUserNameResponse();
var result = await CallInterceptor(
interceptor,
new SetUserNameRequest(),
context,
() => expected);
Assert.Same(expected, result);
}
/// <summary>
/// Verifies that when the userId is valid but the user is not in the store,
/// the interceptor still returns the response without crashing.
/// </summary>
[Fact]
public async Task UnknownUser_ContinuationStillCalled()
{
var store = CreateEmptyStore();
var interceptor = CreateInterceptor(store);
var context = FakeServerCallContext.For(userId: 999);
var expected = new SetUserNameResponse();
var result = await CallInterceptor(
interceptor,
new SetUserNameRequest(),
context,
() => expected);
Assert.Same(expected, result);
}
}