using MariesWonderland.Data;
namespace MariesWonderland.Tests.Infrastructure;
///
/// Base class for service-level tests. Concrete test classes should implement
/// IClassFixture<MasterDatabaseFixture> and pass the fixture here.
///
public abstract class ServiceTestBase
{
protected DarkMasterMemoryDatabase MasterDb { get; }
protected GameConfig GameConfig { get; }
protected ServiceTestBase(MasterDatabaseFixture fixture)
{
MasterDb = fixture.MasterDb;
GameConfig = fixture.GameConfig;
}
/// Creates a fresh empty user database.
protected static DarkUserMemoryDatabase CreateUserDb() => new();
///
/// Creates a pre-loaded with the given user database
/// so that store.GetOrCreate(userId) returns .
///
protected static UserDataStore CreateStore(long userId, DarkUserMemoryDatabase userDb, DarkMasterMemoryDatabase masterDb)
{
var store = new UserDataStore(masterDb);
store.Set(userId, userDb);
return store;
}
/// Shorthand for .
protected static FakeServerCallContext ContextFor(long userId = 1)
=> FakeServerCallContext.For(userId);
}