1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Add test coverage of two beatmaps in same set with different audio files

This commit is contained in:
Dean Herbert 2022-07-18 17:01:45 +09:00
parent b8c90266de
commit 18da9ddfbf
2 changed files with 39 additions and 3 deletions

View File

@ -62,9 +62,45 @@ namespace osu.Game.Tests.NonVisual
Assert.IsTrue(beatmapSetA.Beatmaps.Single().AudioEquals(beatmapSetB.Beatmaps.Single()));
}
private static void addAudioFile(BeatmapSetInfo beatmapSetInfo, string hash = null)
[Test]
public void TestAudioEqualityBeatmapInfoSameHash()
{
beatmapSetInfo.Files.Add(new RealmNamedFileUsage(new RealmFile { Hash = hash ?? Guid.NewGuid().ToString() }, "audio.mp3"));
var beatmapSet = TestResources.CreateTestBeatmapSetInfo(2);
addAudioFile(beatmapSet);
var beatmap1 = beatmapSet.Beatmaps.First();
var beatmap2 = beatmapSet.Beatmaps.Last();
Assert.AreNotEqual(beatmap1, beatmap2);
Assert.IsTrue(beatmap1.AudioEquals(beatmap2));
}
[Test]
public void TestAudioEqualityBeatmapInfoDifferentHash()
{
var beatmapSet = TestResources.CreateTestBeatmapSetInfo(2);
const string filename1 = "audio1.mp3";
const string filename2 = "audio2.mp3";
addAudioFile(beatmapSet, filename: filename1);
addAudioFile(beatmapSet, filename: filename2);
var beatmap1 = beatmapSet.Beatmaps.First();
var beatmap2 = beatmapSet.Beatmaps.Last();
Assert.AreNotEqual(beatmap1, beatmap2);
beatmap1.Metadata.AudioFile = filename1;
beatmap2.Metadata.AudioFile = filename2;
Assert.IsFalse(beatmap1.AudioEquals(beatmap2));
}
private static void addAudioFile(BeatmapSetInfo beatmapSetInfo, string hash = null, string filename = null)
{
beatmapSetInfo.Files.Add(new RealmNamedFileUsage(new RealmFile { Hash = hash ?? Guid.NewGuid().ToString() }, filename ?? "audio.mp3"));
}
[Test]

View File

@ -138,7 +138,7 @@ namespace osu.Game.Tests.Resources
BPM = bpm,
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
Ruleset = rulesetInfo,
Metadata = metadata,
Metadata = metadata.DeepClone(),
Difficulty = new BeatmapDifficulty
{
OverallDifficulty = diff,