mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 11:42:56 +08:00
Add helper method for editor check tests
This commit is contained in:
parent
c2f8d9f677
commit
c7bc03e6f7
@ -12,7 +12,6 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using FileInfo = osu.Game.IO.FileInfo;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Editing.Checks
|
namespace osu.Game.Tests.Editing.Checks
|
||||||
{
|
{
|
||||||
@ -34,11 +33,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
Files =
|
Files =
|
||||||
{
|
{
|
||||||
new BeatmapSetFileInfo
|
CheckTestHelpers.CreateMockFile("mp4"),
|
||||||
{
|
|
||||||
Filename = "abc123.mp4",
|
|
||||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Checks;
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using FileInfo = osu.Game.IO.FileInfo;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Editing.Checks
|
namespace osu.Game.Tests.Editing.Checks
|
||||||
{
|
{
|
||||||
@ -25,25 +24,17 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
|
var file = CheckTestHelpers.CreateMockFile("jpg");
|
||||||
|
|
||||||
check = new CheckBackgroundQuality();
|
check = new CheckBackgroundQuality();
|
||||||
beatmap = new Beatmap<HitObject>
|
beatmap = new Beatmap<HitObject>
|
||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
Metadata = new BeatmapMetadata { BackgroundFile = file.Filename },
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Files =
|
Files = { file }
|
||||||
{
|
|
||||||
new BeatmapSetFileInfo
|
|
||||||
{
|
|
||||||
Filename = "abc123.jpg",
|
|
||||||
FileInfo = new FileInfo
|
|
||||||
{
|
|
||||||
Hash = "abcdef"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.IO;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Checks;
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -21,22 +20,17 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
|
var file = CheckTestHelpers.CreateMockFile("jpg");
|
||||||
|
|
||||||
check = new CheckBackgroundPresence();
|
check = new CheckBackgroundPresence();
|
||||||
beatmap = new Beatmap<HitObject>
|
beatmap = new Beatmap<HitObject>
|
||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
Metadata = new BeatmapMetadata { BackgroundFile = file.Filename },
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Files =
|
Files = { file }
|
||||||
{
|
|
||||||
new BeatmapSetFileInfo
|
|
||||||
{
|
|
||||||
Filename = "abc123.jpg",
|
|
||||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
18
osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
Normal file
18
osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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 osu.Game.Beatmaps;
|
||||||
|
using osu.Game.IO;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Editing.Checks
|
||||||
|
{
|
||||||
|
public static class CheckTestHelpers
|
||||||
|
{
|
||||||
|
public static BeatmapSetFileInfo CreateMockFile(string extension) =>
|
||||||
|
new BeatmapSetFileInfo
|
||||||
|
{
|
||||||
|
Filename = $"abc123.{extension}",
|
||||||
|
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,6 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK.Audio;
|
using osuTK.Audio;
|
||||||
using FileInfo = osu.Game.IO.FileInfo;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Editing.Checks
|
namespace osu.Game.Tests.Editing.Checks
|
||||||
{
|
{
|
||||||
@ -33,14 +32,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Files =
|
Files = { CheckTestHelpers.CreateMockFile("wav") }
|
||||||
{
|
|
||||||
new BeatmapSetFileInfo
|
|
||||||
{
|
|
||||||
Filename = "abc123.wav",
|
|
||||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -54,11 +46,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
public void TestDifferentExtension()
|
public void TestDifferentExtension()
|
||||||
{
|
{
|
||||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
||||||
beatmap.BeatmapInfo.BeatmapSet.Files.Add(new BeatmapSetFileInfo
|
beatmap.BeatmapInfo.BeatmapSet.Files.Add(CheckTestHelpers.CreateMockFile("jpg"));
|
||||||
{
|
|
||||||
Filename = "abc123.jpg",
|
|
||||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
|
||||||
});
|
|
||||||
|
|
||||||
// Should fail to load, but not produce an error due to the extension not being expected to load.
|
// Should fail to load, but not produce an error due to the extension not being expected to load.
|
||||||
Assert.IsEmpty(check.Run(getContext(null, allowMissing: true)));
|
Assert.IsEmpty(check.Run(getContext(null, allowMissing: true)));
|
||||||
|
@ -9,7 +9,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Checks;
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using FileInfo = osu.Game.IO.FileInfo;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Editing.Checks
|
namespace osu.Game.Tests.Editing.Checks
|
||||||
{
|
{
|
||||||
@ -31,11 +30,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
Files =
|
Files =
|
||||||
{
|
{
|
||||||
new BeatmapSetFileInfo
|
CheckTestHelpers.CreateMockFile("jpg"),
|
||||||
{
|
|
||||||
Filename = "abc123.jpg",
|
|
||||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user