1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:42:54 +08:00
osu-lazer/osu.Game/Tests/Beatmaps/LegacyModConversionTest.cs
Bartłomiej Dach a407e267a2 Fix PF/SD legacy mod conversion
Upon investigating an user report in #6091 that indicated that viewing
replays using the Perfect mod would also display the Sudden Death mod
icon despite Perfect being the more restrictive of the two, it turned
out that the logic of importing legacy scores was missing that corner
case. A similar case of Double Time/Nightcore mutual exclusion was
handled, but PF/SD was missed.

Add analogous handling of PF/SD legacy mods for all four rulesets,
and additionally cover a tiny fraction of all cases with unit tests.
The most problematic cases (NC+HD and PF+SD) are covered in all four
basic rulesets.
2019-09-15 22:55:25 +02:00

36 lines
1.1 KiB
C#

// 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;
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets;
namespace osu.Game.Tests.Beatmaps
{
/// <summary>
/// Base class for tests of converting <see cref="LegacyMods"/> enumeration flags to ruleset mod instances.
/// </summary>
public abstract class LegacyModConversionTest
{
/// <summary>
/// Creates the <see cref="Ruleset"/> whose legacy mod conversion is to be tested.
/// </summary>
/// <returns></returns>
protected abstract Ruleset CreateRuleset();
protected void Test(LegacyMods legacyMods, Type[] expectedMods)
{
var ruleset = CreateRuleset();
var mods = ruleset.ConvertLegacyMods(legacyMods).ToList();
Assert.AreEqual(expectedMods.Length, mods.Count);
foreach (var modType in expectedMods)
{
Assert.IsNotNull(mods.SingleOrDefault(mod => mod.GetType() == modType));
}
}
}
}