2021-04-12 23:22:24 +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.
|
|
|
|
|
|
|
|
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;
|
2021-04-17 15:33:53 +00:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-04-12 23:22:24 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Editing.Checks
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2021-04-18 00:07:33 +00:00
|
|
|
public class CheckFilePresenceTest
|
2021-04-12 23:22:24 +00:00
|
|
|
{
|
2021-04-18 00:07:33 +00:00
|
|
|
private CheckBackgroundPresence check;
|
2021-04-19 23:31:51 +00:00
|
|
|
private IBeatmap beatmap;
|
2021-04-12 23:22:24 +00:00
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2021-04-18 00:07:33 +00:00
|
|
|
check = new CheckBackgroundPresence();
|
2021-04-19 23:31:51 +00:00
|
|
|
beatmap = new Beatmap<HitObject>
|
2021-04-12 23:22:24 +00:00
|
|
|
{
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
{
|
|
|
|
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
|
|
|
BeatmapSet = new BeatmapSetInfo
|
|
|
|
{
|
2021-04-13 00:17:35 +00:00
|
|
|
Files = new List<BeatmapSetFileInfo>(new[]
|
2021-04-12 23:22:24 +00:00
|
|
|
{
|
|
|
|
new BeatmapSetFileInfo { Filename = "abc123.jpg" }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-04-19 23:31:51 +00:00
|
|
|
};
|
2021-04-12 23:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundSetAndInFiles()
|
|
|
|
{
|
2021-04-19 23:31:51 +00:00
|
|
|
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
2021-04-12 23:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundSetAndNotInFiles()
|
|
|
|
{
|
|
|
|
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
|
|
|
|
2021-04-19 23:31:51 +00:00
|
|
|
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
2021-04-12 23:22:24 +00:00
|
|
|
|
2021-04-13 06:04:01 +00:00
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2021-04-18 00:07:33 +00:00
|
|
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
2021-04-12 23:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBackgroundNotSet()
|
|
|
|
{
|
|
|
|
beatmap.Metadata.BackgroundFile = null;
|
|
|
|
|
2021-04-19 23:31:51 +00:00
|
|
|
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
2021-04-12 23:22:24 +00:00
|
|
|
|
2021-04-13 06:04:01 +00:00
|
|
|
Assert.That(issues, Has.Count.EqualTo(1));
|
2021-04-18 00:07:33 +00:00
|
|
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
2021-04-12 23:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|