public void TestGetPlayableDefaultTimeout() { var working = new TestNeverLoadsWorkingBeatmap(); Assert.Throws(Is.InstanceOf <TimeoutException>(), () => working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo)); working.ResetEvent.Set(); }
public void TestGetPlayableSuccess() { var working = new TestNeverLoadsWorkingBeatmap(); working.ResetEvent.Set(); Assert.NotNull(working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo)); }
public void TestGetPlayableCancellationToken() { var working = new TestNeverLoadsWorkingBeatmap(); var cts = new CancellationTokenSource(); var loadStarted = new ManualResetEventSlim(); var loadCompleted = new ManualResetEventSlim(); Task.Factory.StartNew(() => { loadStarted.Set(); Assert.Throws <OperationCanceledException>(() => working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty <Mod>(), cts.Token)); loadCompleted.Set(); }, TaskCreationOptions.LongRunning); Assert.IsTrue(loadStarted.Wait(10000)); cts.Cancel(); Assert.IsTrue(loadCompleted.Wait(10000)); working.ResetEvent.Set(); }