mirror of
https://github.com/ppy/osu
synced 2025-03-11 05:49:12 +00:00
Update RealmLive
tests in line with modified behaviour
This commit is contained in:
parent
348d1d0be9
commit
4c2b0dd2d1
@ -82,19 +82,29 @@ namespace osu.Game.Tests.Database
|
|||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
Assert.DoesNotThrow(() =>
|
// TODO: The commented code is the behaviour we hope to obtain, but is temporarily disabled.
|
||||||
|
// See https://github.com/ppy/osu/pull/15851
|
||||||
|
using (realmFactory.CreateContext())
|
||||||
{
|
{
|
||||||
using (realmFactory.CreateContext())
|
Assert.Throws<InvalidOperationException>(() =>
|
||||||
{
|
{
|
||||||
var resolved = liveBeatmap.Value;
|
var __ = liveBeatmap.Value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Assert.IsTrue(resolved.Realm.IsClosed);
|
// Assert.DoesNotThrow(() =>
|
||||||
Assert.IsTrue(resolved.IsValid);
|
// {
|
||||||
|
// using (realmFactory.CreateContext())
|
||||||
// can access properties without a crash.
|
// {
|
||||||
Assert.IsFalse(resolved.Hidden);
|
// var resolved = liveBeatmap.Value;
|
||||||
}
|
//
|
||||||
});
|
// Assert.IsTrue(resolved.Realm.IsClosed);
|
||||||
|
// Assert.IsTrue(resolved.IsValid);
|
||||||
|
//
|
||||||
|
// // can access properties without a crash.
|
||||||
|
// Assert.IsFalse(resolved.Hidden);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -215,23 +225,29 @@ namespace osu.Game.Tests.Database
|
|||||||
Assert.AreEqual(0, updateThreadContext.All<RealmBeatmap>().Count());
|
Assert.AreEqual(0, updateThreadContext.All<RealmBeatmap>().Count());
|
||||||
Assert.AreEqual(0, changesTriggered);
|
Assert.AreEqual(0, changesTriggered);
|
||||||
|
|
||||||
var resolved = liveBeatmap.Value;
|
// TODO: Originally the following was using `liveBeatmap.Value`. This has been temporarily disabled.
|
||||||
|
// See https://github.com/ppy/osu/pull/15851
|
||||||
// retrieval causes an implicit refresh. even changes that aren't related to the retrieval are fired at this point.
|
liveBeatmap.PerformRead(resolved =>
|
||||||
Assert.AreEqual(2, updateThreadContext.All<RealmBeatmap>().Count());
|
|
||||||
Assert.AreEqual(1, changesTriggered);
|
|
||||||
|
|
||||||
// even though the realm that this instance was resolved for was closed, it's still valid.
|
|
||||||
Assert.IsTrue(resolved.Realm.IsClosed);
|
|
||||||
Assert.IsTrue(resolved.IsValid);
|
|
||||||
|
|
||||||
// can access properties without a crash.
|
|
||||||
Assert.IsFalse(resolved.Hidden);
|
|
||||||
|
|
||||||
updateThreadContext.Write(r =>
|
|
||||||
{
|
{
|
||||||
// can use with the main context.
|
// retrieval causes an implicit refresh. even changes that aren't related to the retrieval are fired at this point.
|
||||||
r.Remove(resolved);
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
|
Assert.AreEqual(2, updateThreadContext.All<RealmBeatmap>().Count());
|
||||||
|
Assert.AreEqual(1, changesTriggered);
|
||||||
|
|
||||||
|
// TODO: as above, temporarily disabled as it doesn't make sense inside a `PerformRead`.
|
||||||
|
// // even though the realm that this instance was resolved for was closed, it's still valid.
|
||||||
|
// Assert.IsTrue(resolved.Realm.IsClosed);
|
||||||
|
// Assert.IsTrue(resolved.IsValid);
|
||||||
|
|
||||||
|
// can access properties without a crash.
|
||||||
|
Assert.IsFalse(resolved.Hidden);
|
||||||
|
|
||||||
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
|
updateThreadContext.Write(r =>
|
||||||
|
{
|
||||||
|
// can use with the main context.
|
||||||
|
r.Remove(resolved);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user