1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 12:37:29 +08:00
osu-lazer/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
2.6 KiB
C#
Raw Normal View History

2023-07-10 22:29:59 +08:00
// 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.
2023-07-11 18:40:27 +08:00
using System.Collections.Generic;
2023-07-10 22:29:59 +08:00
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Editing.Checks
{
public class CheckDrainTimeTest
{
private CheckDrainTime check = null!;
[SetUp]
public void Setup()
{
check = new CheckDrainTime();
}
[Test]
public void TestDrainTimeShort()
{
2023-07-11 18:40:27 +08:00
assertShortDrainTime(getShortDrainTimeBeatmap());
}
2023-07-10 22:29:59 +08:00
2023-07-11 18:40:27 +08:00
[Test]
public void TestDrainTimeBreak()
{
assertShortDrainTime(getLongBreakBeatmap());
}
2023-07-10 22:29:59 +08:00
2023-07-11 18:40:27 +08:00
[Test]
public void TestDrainTimeCorrect()
{
assertOk(getCorrectDrainTimeBeatmap());
2023-07-10 22:29:59 +08:00
}
2023-07-11 18:40:27 +08:00
private IBeatmap getShortDrainTimeBeatmap()
2023-07-10 22:29:59 +08:00
{
2023-07-11 18:40:27 +08:00
return new Beatmap<HitObject>
2023-07-10 22:29:59 +08:00
{
HitObjects =
{
2023-07-11 18:40:27 +08:00
new HitCircle { StartTime = 0 }
2023-07-10 22:29:59 +08:00
}
};
}
2023-07-11 18:40:27 +08:00
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 assertOk(IBeatmap beatmap)
{
var issues = check.Run(getContext(beatmap)).ToList();
Assert.That(issues, Is.Empty);
}
private BeatmapVerifierContext getContext(IBeatmap beatmap)
{
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
}
2023-07-10 22:29:59 +08:00
}
}