osu/osu.Game.Tests/Editing/Checks/CheckFilePresenceTest.cs

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

71 lines
2.2 KiB
C#
Raw Normal View History

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