mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Make more tests use the custom mod classes
For safety purposes... In implementing the previous tests, I found that using mod.Object.GetType() can lead to bad assertions since the same ModProxy class is used for all mocked classes.
This commit is contained in:
parent
1df412a03c
commit
9955e02898
@ -14,37 +14,37 @@ namespace osu.Game.Tests.Mods
|
||||
[Test]
|
||||
public void TestModIsCompatibleByItself()
|
||||
{
|
||||
var mod = new Mock<Mod>();
|
||||
var mod = new Mock<CustomMod1>();
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod.Object }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIncompatibleThroughTopLevel()
|
||||
{
|
||||
var mod1 = new Mock<Mod>();
|
||||
var mod2 = new Mock<Mod>();
|
||||
var mod1 = new Mock<CustomMod1>();
|
||||
var mod2 = new Mock<CustomMod2>();
|
||||
|
||||
mod1.Setup(m => m.IncompatibleMods).Returns(new[] { mod2.Object.GetType() });
|
||||
|
||||
// Test both orderings.
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod1.Object, mod2.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod2.Object, mod1.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultiModIncompatibleWithTopLevel()
|
||||
{
|
||||
var mod1 = new Mock<Mod>();
|
||||
var mod1 = new Mock<CustomMod1>();
|
||||
|
||||
// The nested mod.
|
||||
var mod2 = new Mock<Mod>();
|
||||
var mod2 = new Mock<CustomMod2>();
|
||||
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { mod1.Object.GetType() });
|
||||
|
||||
var multiMod = new MultiMod(new MultiMod(mod2.Object));
|
||||
|
||||
// Test both orderings.
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { multiMod, mod1.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod1.Object, multiMod }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { multiMod, mod1.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, multiMod }), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -65,37 +65,37 @@ namespace osu.Game.Tests.Mods
|
||||
[Test]
|
||||
public void TestCompatibleMods()
|
||||
{
|
||||
var mod1 = new Mock<Mod>();
|
||||
var mod2 = new Mock<Mod>();
|
||||
var mod1 = new Mock<CustomMod1>();
|
||||
var mod2 = new Mock<CustomMod2>();
|
||||
|
||||
// Test both orderings.
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod1.Object, mod2.Object }), Is.True);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod2.Object, mod1.Object }), Is.True);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.True);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIncompatibleThroughBaseType()
|
||||
{
|
||||
var mod1 = new Mock<Mod>();
|
||||
var mod2 = new Mock<Mod>();
|
||||
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { mod1.Object.GetType().BaseType });
|
||||
var mod1 = new Mock<CustomMod1>();
|
||||
var mod2 = new Mock<CustomMod2>();
|
||||
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { typeof(Mod) });
|
||||
|
||||
// Test both orderings.
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod1.Object, mod2.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod2.Object, mod1.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.False);
|
||||
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAllowedThroughMostDerivedType()
|
||||
{
|
||||
var mod = new Mock<Mod>();
|
||||
var mod = new Mock<CustomMod1>();
|
||||
Assert.That(ModUtils.CheckAllowed(new[] { mod.Object }, new[] { mod.Object.GetType() }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotAllowedThroughBaseType()
|
||||
{
|
||||
var mod = new Mock<Mod>();
|
||||
var mod = new Mock<CustomMod1>();
|
||||
Assert.That(ModUtils.CheckAllowed(new[] { mod.Object }, new[] { typeof(Mod) }), Is.False);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user