Example #1
0
        public void TestGetPlayableDefaultTimeout()
        {
            var working = new TestNeverLoadsWorkingBeatmap();

            Assert.Throws(Is.InstanceOf <TimeoutException>(), () => working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));

            working.ResetEvent.Set();
        }
Example #2
0
        public void TestGetPlayableSuccess()
        {
            var working = new TestNeverLoadsWorkingBeatmap();

            working.ResetEvent.Set();

            Assert.NotNull(working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));
        }
Example #3
0
        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();
        }