mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Fix broken test due to SynchronizationContext
never running expected work
This commit is contained in:
parent
8116806db3
commit
56d7d81465
@ -87,6 +87,11 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
hasThreadedUsage.Wait();
|
||||
|
||||
// Usually the host would run the synchronization context work per frame.
|
||||
// For the sake of keeping this test simple (there's only one update invocation),
|
||||
// let's replace it so we can ensure work is run immediately.
|
||||
SynchronizationContext.SetSynchronizationContext(new ImmediateExecuteSynchronizationContext());
|
||||
|
||||
Assert.Throws<TimeoutException>(() =>
|
||||
{
|
||||
using (realm.BlockAllOperations())
|
||||
@ -102,5 +107,10 @@ namespace osu.Game.Tests.Database
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class ImmediateExecuteSynchronizationContext : SynchronizationContext
|
||||
{
|
||||
public override void Post(SendOrPostCallback d, object? state) => d(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user