// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Edit.Checks; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Tests.Beatmaps; namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks { [TestFixture] public class CheckTooShortSpinnersTest { private CheckTooShortSpinners check; private BeatmapDifficulty difficulty; [SetUp] public void Setup() { check = new CheckTooShortSpinners(); difficulty = new BeatmapDifficulty(); } [Test] public void TestLongSpinner() { Spinner spinner = new Spinner { StartTime = 0, Duration = 4000 }; spinner.ApplyDefaults(new ControlPointInfo(), difficulty); assertOk(new List { spinner }, difficulty); } [Test] public void TestShortSpinner() { Spinner spinner = new Spinner { StartTime = 0, Duration = 750 }; spinner.ApplyDefaults(new ControlPointInfo(), difficulty); assertOk(new List { spinner }, difficulty); } [Test] public void TestVeryShortSpinner() { // Spinners at a certain duration only get 1000 points if approached by auto at a certain angle, making it difficult to determine. Spinner spinner = new Spinner { StartTime = 0, Duration = 475 }; spinner.ApplyDefaults(new ControlPointInfo(), difficulty); assertVeryShort(new List { spinner }, difficulty); } [Test] public void TestTooShortSpinner() { Spinner spinner = new Spinner { StartTime = 0, Duration = 400 }; spinner.ApplyDefaults(new ControlPointInfo(), difficulty); assertTooShort(new List { spinner }, difficulty); } [Test] public void TestTooShortSpinnerVaryingOd() { const double duration = 450; var difficultyLowOd = new BeatmapDifficulty { OverallDifficulty = 1 }; Spinner spinnerLowOd = new Spinner { StartTime = 0, Duration = duration }; spinnerLowOd.ApplyDefaults(new ControlPointInfo(), difficultyLowOd); var difficultyHighOd = new BeatmapDifficulty { OverallDifficulty = 10 }; Spinner spinnerHighOd = new Spinner { StartTime = 0, Duration = duration }; spinnerHighOd.ApplyDefaults(new ControlPointInfo(), difficultyHighOd); assertOk(new List { spinnerLowOd }, difficultyLowOd); assertTooShort(new List { spinnerHighOd }, difficultyHighOd); } private void assertOk(List hitObjects, BeatmapDifficulty beatmapDifficulty) { Assert.That(check.Run(getContext(hitObjects, beatmapDifficulty)), Is.Empty); } private void assertVeryShort(List hitObjects, BeatmapDifficulty beatmapDifficulty) { var issues = check.Run(getContext(hitObjects, beatmapDifficulty)).ToList(); Assert.That(issues, Has.Count.EqualTo(1)); Assert.That(issues.First().Template is CheckTooShortSpinners.IssueTemplateVeryShort); } private void assertTooShort(List hitObjects, BeatmapDifficulty beatmapDifficulty) { var issues = check.Run(getContext(hitObjects, beatmapDifficulty)).ToList(); Assert.That(issues, Has.Count.EqualTo(1)); Assert.That(issues.First().Template is CheckTooShortSpinners.IssueTemplateTooShort); } private BeatmapVerifierContext getContext(List hitObjects, BeatmapDifficulty beatmapDifficulty) { var beatmap = new Beatmap { HitObjects = hitObjects, BeatmapInfo = new BeatmapInfo { BaseDifficulty = beatmapDifficulty } }; return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); } } }