1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 14:40:04 +08:00
osu-lazer/osu.Game.Tests/Editing/Checks/CheckDrainLengthTest.cs

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

86 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.Beatmaps.Timing;
2023-07-10 22:29:59 +08:00
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
{
2023-07-26 04:18:31 +08:00
public class CheckDrainLengthTest
2023-07-10 22:29:59 +08:00
{
private CheckDrainLength check = null!;
2023-07-10 22:29:59 +08:00
[SetUp]
public void Setup()
{
check = new CheckDrainLength();
2023-07-10 22:29:59 +08:00
}
[Test]
public void TestDrainTimeShort()
{
var beatmap = new Beatmap<HitObject>
2023-07-10 22:29:59 +08:00
{
HitObjects =
{
new HitCircle { StartTime = 0 },
new HitCircle { StartTime = 29_999 }
2023-07-10 22:29:59 +08:00
}
};
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 CheckDrainLength.IssueTemplateTooShort);
2023-07-10 22:29:59 +08:00
}
2023-07-11 18:40:27 +08:00
[Test]
public void TestDrainTimeBreak()
2023-07-11 18:40:27 +08:00
{
var beatmap = new Beatmap<HitObject>
2023-07-11 18:40:27 +08:00
{
HitObjects =
{
new HitCircle { StartTime = 0 },
new HitCircle { StartTime = 40_000 }
},
Breaks = new List<BreakPeriod>
{
new BreakPeriod(10_000, 21_000)
2023-07-11 18:40:27 +08:00
}
};
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 CheckDrainLength.IssueTemplateTooShort);
2023-07-11 18:40:27 +08:00
}
[Test]
public void TestDrainTimeCorrect()
2023-07-11 18:40:27 +08:00
{
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));
2023-07-11 18:40:27 +08:00
var issues = check.Run(context).ToList();
2023-07-11 18:40:27 +08:00
Assert.That(issues, Is.Empty);
}
2023-07-10 22:29:59 +08:00
}
}