mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:43:10 +08:00
Merge pull request #15868 from smoogipoo/refactor-test
Refactor difficulty adjustment mod combinations test
This commit is contained in:
commit
a89e18de42
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Difficulty.Skills;
|
using osu.Game.Rulesets.Difficulty.Skills;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Tests.NonVisual
|
namespace osu.Game.Tests.NonVisual
|
||||||
{
|
{
|
||||||
@ -20,8 +22,10 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator().CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator().CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(1, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
|
new[] { typeof(ModNoMod) }
|
||||||
|
}, combinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -29,9 +33,11 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(2, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
|
new[] { typeof(ModA) }
|
||||||
|
}, combinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -39,14 +45,13 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(4, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is MultiMod);
|
new[] { typeof(ModA) },
|
||||||
Assert.IsTrue(combinations[3] is ModB);
|
new[] { typeof(ModA), typeof(ModB) },
|
||||||
|
new[] { typeof(ModB) }
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
}, combinations);
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -54,10 +59,12 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(3, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is ModIncompatibleWithA);
|
new[] { typeof(ModA) },
|
||||||
|
new[] { typeof(ModIncompatibleWithA) }
|
||||||
|
}, combinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -65,22 +72,17 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(8, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is MultiMod);
|
new[] { typeof(ModA) },
|
||||||
Assert.IsTrue(combinations[3] is ModB);
|
new[] { typeof(ModA), typeof(ModB) },
|
||||||
Assert.IsTrue(combinations[4] is MultiMod);
|
new[] { typeof(ModB) },
|
||||||
Assert.IsTrue(combinations[5] is ModIncompatibleWithA);
|
new[] { typeof(ModB), typeof(ModIncompatibleWithA) },
|
||||||
Assert.IsTrue(combinations[6] is MultiMod);
|
new[] { typeof(ModIncompatibleWithA) },
|
||||||
Assert.IsTrue(combinations[7] is ModIncompatibleWithAAndB);
|
new[] { typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB) },
|
||||||
|
new[] { typeof(ModIncompatibleWithAAndB) },
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
}, combinations);
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[4]).Mods[0] is ModB);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[4]).Mods[1] is ModIncompatibleWithA);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[6]).Mods[0] is ModIncompatibleWithA);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[6]).Mods[1] is ModIncompatibleWithAAndB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -88,10 +90,12 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(3, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModAofA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is ModIncompatibleWithAofA);
|
new[] { typeof(ModAofA) },
|
||||||
|
new[] { typeof(ModIncompatibleWithAofA) }
|
||||||
|
}, combinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -99,17 +103,13 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModB(), new ModC())).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModB(), new ModC())).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(4, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is MultiMod);
|
new[] { typeof(ModA) },
|
||||||
Assert.IsTrue(combinations[3] is MultiMod);
|
new[] { typeof(ModA), typeof(ModB), typeof(ModC) },
|
||||||
|
new[] { typeof(ModB), typeof(ModC) }
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
}, combinations);
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[2] is ModC);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[3]).Mods[0] is ModB);
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[3]).Mods[1] is ModC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -117,13 +117,12 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModB(), new ModIncompatibleWithA())).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModB(), new ModIncompatibleWithA())).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(3, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is MultiMod);
|
new[] { typeof(ModA) },
|
||||||
|
new[] { typeof(ModB), typeof(ModIncompatibleWithA) }
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModB);
|
}, combinations);
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModIncompatibleWithA);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -131,13 +130,28 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModA(), new ModB())).CreateDifficultyAdjustmentModCombinations();
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new MultiMod(new ModA(), new ModB())).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
Assert.AreEqual(3, combinations.Length);
|
assertCombinations(new[]
|
||||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
{
|
||||||
Assert.IsTrue(combinations[1] is ModA);
|
new[] { typeof(ModNoMod) },
|
||||||
Assert.IsTrue(combinations[2] is MultiMod);
|
new[] { typeof(ModA) },
|
||||||
|
new[] { typeof(ModA), typeof(ModB) }
|
||||||
|
}, combinations);
|
||||||
|
}
|
||||||
|
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
private void assertCombinations(Type[][] expectedCombinations, Mod[] actualCombinations)
|
||||||
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
{
|
||||||
|
Assert.AreEqual(expectedCombinations.Length, actualCombinations.Length);
|
||||||
|
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < expectedCombinations.Length; ++i)
|
||||||
|
{
|
||||||
|
Type[] expectedTypes = expectedCombinations[i];
|
||||||
|
Type[] actualTypes = ModUtils.FlattenMod(actualCombinations[i]).Select(m => m.GetType()).ToArray();
|
||||||
|
|
||||||
|
Assert.That(expectedTypes, Is.EquivalentTo(actualTypes));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ModA : Mod
|
private class ModA : Mod
|
||||||
|
Loading…
Reference in New Issue
Block a user