mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Apply feedback to tests
This commit is contained in:
parent
1dae1d8f0a
commit
d75887bb3b
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -16,8 +17,6 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
private CheckDrainTime check = null!;
|
||||
|
||||
private IBeatmap beatmap = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@ -27,24 +26,77 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestDrainTimeShort()
|
||||
{
|
||||
setShortDrainTimeBeatmap();
|
||||
var content = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
assertShortDrainTime(getShortDrainTimeBeatmap());
|
||||
}
|
||||
|
||||
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.Single().Template is CheckDrainTime.IssueTemplateTooShort);
|
||||
}
|
||||
|
||||
private void setShortDrainTimeBeatmap()
|
||||
private void assertOk(IBeatmap beatmap)
|
||||
{
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle()
|
||||
}
|
||||
};
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Is.Empty);
|
||||
}
|
||||
|
||||
private BeatmapVerifierContext getContext(IBeatmap beatmap)
|
||||
{
|
||||
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user