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.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Beatmaps;
|
2021-05-12 08:29:18 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
2021-04-13 07:22:24 +08:00
|
|
|
using osu.Game.Rulesets.Edit.Checks;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2021-04-17 23:33:53 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-04-13 07:22:24 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Editing.Checks
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2021-04-18 08:07:33 +08:00
|
|
|
public class CheckFilePresenceTest
|
2021-04-13 07:22:24 +08:00
|
|
|
{
|
2022-10-30 16:36:22 +08:00
|
|
|
private CheckBackgroundPresence check = null!;
|
|
|
|
private IBeatmap beatmap = null!;
|
2021-04-13 07:22:24 +08:00
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2021-11-24 13:22:41 +08:00
|
|
|
var file = CheckTestHelpers.CreateMockFile("jpg");
|
|
|
|
|
2021-04-18 08:07:33 +08:00
|
|
|
check = new CheckBackgroundPresence();
|
2021-04-20 07:31:51 +08:00
|
|
|
beatmap = new Beatmap<HitObject>
|
2021-04-13 07:22:24 +08:00
|
|
|
{
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
{
|
2021-11-24 13:22:41 +08:00
|
|
|
Metadata = new BeatmapMetadata { BackgroundFile = file.Filename },
|
2021-04-13 07:22:24 +08:00
|
|
|
BeatmapSet = new BeatmapSetInfo
|
|
|
|
{
|
2021-11-24 13:22:41 +08:00
|
|
|
Files = { file }
|
2021-04-13 07:22:24 +08:00
|
|
|
}
|
|
|
|
}
|
2021-04-20 07:31:51 +08:00
|
|
|
};
|
2021-04-13 07:22:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundSetAndInFiles()
|
|
|
|
{
|
2021-05-13 17:24:22 +08:00
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
|
|
|
Assert.That(check.Run(context), Is.Empty);
|
2021-04-13 07:22:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundSetAndNotInFiles()
|
|
|
|
{
|
2021-11-22 13:24:17 +08:00
|
|
|
beatmap.BeatmapInfo.BeatmapSet?.Files.Clear();
|
2021-04-13 07:22:24 +08:00
|
|
|
|
2021-05-13 17:24:22 +08:00
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
|
|
|
var issues = check.Run(context).ToList();
|
2021-04-13 07:22:24 +08:00
|
|
|
|
2021-04-13 14:04:01 +08:00
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2021-04-18 08:07:33 +08:00
|
|
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
2021-04-13 07:22:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundNotSet()
|
|
|
|
{
|
2021-11-04 13:50:39 +08:00
|
|
|
beatmap.Metadata.BackgroundFile = string.Empty;
|
2021-04-13 07:22:24 +08:00
|
|
|
|
2021-05-13 17:24:22 +08:00
|
|
|
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
|
|
|
var issues = check.Run(context).ToList();
|
2021-04-13 07:22:24 +08:00
|
|
|
|
2021-04-13 14:04:01 +08:00
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2021-04-18 08:07:33 +08:00
|
|
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
2021-04-13 07:22:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|