1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

Apply feedback to tests

This commit is contained in:
NiceAesth 2023-07-11 13:40:27 +03:00
parent 1dae1d8f0a
commit d75887bb3b

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -16,8 +17,6 @@ namespace osu.Game.Tests.Editing.Checks
{ {
private CheckDrainTime check = null!; private CheckDrainTime check = null!;
private IBeatmap beatmap = null!;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
@ -27,24 +26,77 @@ namespace osu.Game.Tests.Editing.Checks
[Test] [Test]
public void TestDrainTimeShort() public void TestDrainTimeShort()
{ {
setShortDrainTimeBeatmap(); assertShortDrainTime(getShortDrainTimeBeatmap());
var content = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); }
var issues = check.Run(content).ToList(); [Test]
public void TestDrainTimeBreak()
{
assertShortDrainTime(getLongBreakBeatmap());
}
[Test]
public void TestDrainTimeCorrect()
{
assertOk(getCorrectDrainTimeBeatmap());
}
private IBeatmap getShortDrainTimeBeatmap()
{
return new Beatmap<HitObject>
{
HitObjects =
{
new HitCircle { StartTime = 0 }
}
};
}
private IBeatmap getLongBreakBeatmap()
{
return new Beatmap<HitObject>
{
HitObjects =
{
new HitCircle { StartTime = 0 },
new HitCircle { StartTime = 30 }
}
};
}
private IBeatmap getCorrectDrainTimeBeatmap()
{
var hitObjects = new List<HitObject>();
for (int i = 0; i <= 30; ++i)
{
hitObjects.Add(new HitCircle { StartTime = 1000 * i });
}
return new Beatmap<HitObject>
{
HitObjects = hitObjects
};
}
private void assertShortDrainTime(IBeatmap beatmap)
{
var issues = check.Run(getContext(beatmap)).ToList();
Assert.That(issues, Has.Count.EqualTo(1)); Assert.That(issues, Has.Count.EqualTo(1));
Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort); Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort);
} }
private void setShortDrainTimeBeatmap() private void assertOk(IBeatmap beatmap)
{ {
beatmap = new Beatmap<HitObject> var issues = check.Run(getContext(beatmap)).ToList();
{
HitObjects = Assert.That(issues, Is.Empty);
{
new HitCircle()
} }
};
private BeatmapVerifierContext getContext(IBeatmap beatmap)
{
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
} }
} }
} }