mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Rewrite tests to be less aggressively DRY
Four of six helper methods defined in the test were used exactly once; the remaining two were used two times. Splitting helpers there is just too much.
This commit is contained in:
parent
d75887bb3b
commit
9a3cb624a8
@ -26,35 +26,25 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestDrainTimeShort()
|
public void TestDrainTimeShort()
|
||||||
{
|
{
|
||||||
assertShortDrainTime(getShortDrainTimeBeatmap());
|
var beatmap = new Beatmap<HitObject>
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestDrainTimeBreak()
|
|
||||||
{
|
|
||||||
assertShortDrainTime(getLongBreakBeatmap());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestDrainTimeCorrect()
|
|
||||||
{
|
|
||||||
assertOk(getCorrectDrainTimeBeatmap());
|
|
||||||
}
|
|
||||||
|
|
||||||
private IBeatmap getShortDrainTimeBeatmap()
|
|
||||||
{
|
|
||||||
return new Beatmap<HitObject>
|
|
||||||
{
|
{
|
||||||
HitObjects =
|
HitObjects =
|
||||||
{
|
{
|
||||||
new HitCircle { StartTime = 0 }
|
new HitCircle { StartTime = 0 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBeatmap getLongBreakBeatmap()
|
[Test]
|
||||||
|
public void TestDrainTimeBreak()
|
||||||
{
|
{
|
||||||
return new Beatmap<HitObject>
|
var beatmap = new Beatmap<HitObject>
|
||||||
{
|
{
|
||||||
HitObjects =
|
HitObjects =
|
||||||
{
|
{
|
||||||
@ -62,41 +52,28 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
new HitCircle { StartTime = 30 }
|
new HitCircle { StartTime = 30 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
|
||||||
private IBeatmap getCorrectDrainTimeBeatmap()
|
var issues = check.Run(context).ToList();
|
||||||
{
|
|
||||||
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 assertOk(IBeatmap beatmap)
|
[Test]
|
||||||
|
public void TestDrainTimeCorrect()
|
||||||
{
|
{
|
||||||
var issues = check.Run(getContext(beatmap)).ToList();
|
var hitObjects = new List<HitObject>();
|
||||||
|
|
||||||
|
for (int i = 0; i <= 30; ++i)
|
||||||
|
hitObjects.Add(new HitCircle { StartTime = 1000 * i });
|
||||||
|
|
||||||
|
var beatmap = new Beatmap<HitObject> { HitObjects = hitObjects };
|
||||||
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
Assert.That(issues, Is.Empty);
|
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