osu/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.5 KiB
C#
Raw Normal View History

2023-07-10 14:29:59 +00: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 10:40:27 +00:00
using System.Collections.Generic;
2023-07-10 14:29:59 +00:00
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Timing;
2023-07-10 14:29:59 +00: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-25 20:18:31 +00:00
public class CheckDrainLengthTest
2023-07-10 14:29:59 +00:00
{
private CheckDrainLength check = null!;
2023-07-10 14:29:59 +00:00
[SetUp]
public void Setup()
{
check = new CheckDrainLength();
2023-07-10 14:29:59 +00:00
}
[Test]
public void TestDrainTimeShort()
{
var beatmap = new Beatmap<HitObject>
2023-07-10 14:29:59 +00:00
{
HitObjects =
{
new HitCircle { StartTime = 0 },
new HitCircle { StartTime = 29_999 }
2023-07-10 14:29:59 +00: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 14:29:59 +00:00
}
2023-07-11 10:40:27 +00:00
[Test]
public void TestDrainTimeBreak()
2023-07-11 10:40:27 +00:00
{
var beatmap = new Beatmap<HitObject>
2023-07-11 10:40:27 +00:00
{
HitObjects =
{
new HitCircle { StartTime = 0 },
new HitCircle { StartTime = 40_000 }
},
2024-06-19 05:31:53 +00:00
Breaks =
{
new BreakPeriod(10_000, 21_000)
2023-07-11 10:40:27 +00: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 10:40:27 +00:00
}
[Test]
public void TestDrainTimeCorrect()
2023-07-11 10:40:27 +00: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 10:40:27 +00:00
var issues = check.Run(context).ToList();
2023-07-11 10:40:27 +00:00
Assert.That(issues, Is.Empty);
}
2023-07-10 14:29:59 +00:00
}
}