1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 01:57:48 +08:00
osu-lazer/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs

69 lines
2.0 KiB
C#
Raw Normal View History

2021-04-13 07:22:24 +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.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Beatmaps;
2021-04-13 07:22:24 +08:00
namespace osu.Game.Tests.Editing.Checks
{
[TestFixture]
public class CheckFilePresenceTest
2021-04-13 07:22:24 +08:00
{
private CheckBackgroundPresence check;
private WorkingBeatmap beatmap;
2021-04-13 07:22:24 +08:00
[SetUp]
public void Setup()
{
check = new CheckBackgroundPresence();
beatmap = new TestWorkingBeatmap(new Beatmap<HitObject>
2021-04-13 07:22:24 +08:00
{
BeatmapInfo = new BeatmapInfo
{
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
BeatmapSet = new BeatmapSetInfo
{
2021-04-13 08:17:35 +08:00
Files = new List<BeatmapSetFileInfo>(new[]
2021-04-13 07:22:24 +08:00
{
new BeatmapSetFileInfo { Filename = "abc123.jpg" }
})
}
}
});
2021-04-13 07:22:24 +08:00
}
[Test]
public void TestBackgroundSetAndInFiles()
{
Assert.That(check.Run(beatmap), Is.Empty);
2021-04-13 07:22:24 +08:00
}
[Test]
public void TestBackgroundSetAndNotInFiles()
{
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
var issues = check.Run(beatmap).ToList();
Assert.That(issues, Has.Count.EqualTo(1));
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
2021-04-13 07:22:24 +08:00
}
[Test]
public void TestBackgroundNotSet()
{
beatmap.Metadata.BackgroundFile = null;
var issues = check.Run(beatmap).ToList();
Assert.That(issues, Has.Count.EqualTo(1));
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
2021-04-13 07:22:24 +08:00
}
}
}