Files
Abdullah Atta 05af8dd6be tests: run S3Service against a real S3 server
MinioFixture starts a MinIO-compatible server in Docker with Testcontainers (Silo, since MinIO no longer publishes images) and points S3Clients at it. S3ServiceTests cover signed uploads and object sizes, deleting an object and a user's directory, and multipart uploads within and past the storage limit. The interface stub moves out of ApiErrorResponseTests so both can use it. Running the tests now needs Docker.
2026-10-22 13:13:09 +05:00

20 lines
755 B
C#

using System.Reflection;
namespace Notesnook.API.Tests;
// a fake for interfaces: methods without a handler throw NotImplementedException
public class Stub<T> : DispatchProxy where T : class
{
private Dictionary<string, Func<object?[], object?>> handlers = [];
public static T Create(params (string Method, Func<object?[], object?> Handler)[] handlers)
{
var proxy = Create<T, Stub<T>>();
((Stub<T>)(object)proxy).handlers = handlers.ToDictionary((h) => h.Method, (h) => h.Handler);
return proxy;
}
protected override object? Invoke(MethodInfo? method, object?[]? args)
=> handlers.TryGetValue(method!.Name, out var handler) ? handler(args ?? []) : throw new NotImplementedException(method.Name);
}