mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-11-02 14:23:57 +01:00
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.
20 lines
755 B
C#
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);
|
|
}
|