Use RealmContextFactory instead of EF

This commit is contained in:
Dean Herbert
2021-11-23 13:24:26 +09:00
parent 83cbee39de
commit 89d6ffa7f3
4 changed files with 9 additions and 15 deletions

View File

@ -73,9 +73,9 @@ namespace osu.Game.Tests.Visual
/// <remarks>
/// In interactive runs (ie. VisualTests) this will use the user's database if <see cref="UseFreshStoragePerRun"/> is not set to <c>true</c>.
/// </remarks>
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
protected RealmContextFactory ContextFactory => contextFactory.Value;
private Lazy<DatabaseContextFactory> contextFactory;
private Lazy<RealmContextFactory> contextFactory;
/// <summary>
/// Whether a fresh storage should be initialised per test (method) run.
@ -117,14 +117,7 @@ namespace osu.Game.Tests.Visual
Resources = parent.Get<OsuGameBase>().Resources;
contextFactory = new Lazy<DatabaseContextFactory>(() =>
{
var factory = new DatabaseContextFactory(LocalStorage);
using (var usage = factory.Get())
usage.Migrate();
return factory;
});
contextFactory = new Lazy<RealmContextFactory>(() => new RealmContextFactory(LocalStorage, "client"));
RecycleLocalStorage(false);
@ -301,8 +294,9 @@ namespace osu.Game.Tests.Visual
if (MusicController?.TrackLoaded == true)
MusicController.Stop();
if (contextFactory?.IsValueCreated == true)
contextFactory.Value.ResetDatabase();
// TODO: what should we do here, if anything? should we use an in-memory realm in this instance?
// if (contextFactory?.IsValueCreated == true)
// contextFactory.Value.ResetDatabase();
RecycleLocalStorage(true);
}