Update dependencies, replace Moq with NSubstitute
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Moq;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
@@ -9,99 +8,99 @@ public class ChoiceQueueTests
|
||||
[Test]
|
||||
public async Task ChoiceQueue_MovePokemonChoiceNext()
|
||||
{
|
||||
var pokemon1 = new Mock<IPokemon>();
|
||||
var pokemon2 = new Mock<IPokemon>();
|
||||
var pokemon3 = new Mock<IPokemon>();
|
||||
var pokemon4 = new Mock<IPokemon>();
|
||||
var pokemon1 = Substitute.For<IPokemon>();
|
||||
var pokemon2 = Substitute.For<IPokemon>();
|
||||
var pokemon3 = Substitute.For<IPokemon>();
|
||||
var pokemon4 = Substitute.For<IPokemon>();
|
||||
|
||||
var choice1 = new Mock<ITurnChoice>();
|
||||
choice1.Setup(c => c.User).Returns(pokemon1.Object);
|
||||
var choice2 = new Mock<ITurnChoice>();
|
||||
choice2.Setup(c => c.User).Returns(pokemon2.Object);
|
||||
var choice3 = new Mock<ITurnChoice>();
|
||||
choice3.Setup(c => c.User).Returns(pokemon3.Object);
|
||||
var choice4 = new Mock<ITurnChoice>();
|
||||
choice4.Setup(c => c.User).Returns(pokemon4.Object);
|
||||
var choice1 = Substitute.For<ITurnChoice>();
|
||||
choice1.User.Returns(pokemon1);
|
||||
var choice2 = Substitute.For<ITurnChoice>();
|
||||
choice2.User.Returns(pokemon2);
|
||||
var choice3 = Substitute.For<ITurnChoice>();
|
||||
choice3.User.Returns(pokemon3);
|
||||
var choice4 = Substitute.For<ITurnChoice>();
|
||||
choice4.User.Returns(pokemon4);
|
||||
|
||||
var queue = new BattleChoiceQueue([choice1.Object, choice2.Object, choice3.Object, choice4.Object]);
|
||||
var result = queue.MovePokemonChoiceNext(pokemon3.Object);
|
||||
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
|
||||
var result = queue.MovePokemonChoiceNext(pokemon3);
|
||||
await Assert.That(result).IsTrue();
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ChoiceQueue_MovePokemonChoiceNextFailsIfAlreadyExecuted()
|
||||
{
|
||||
var pokemon1 = new Mock<IPokemon>();
|
||||
var pokemon2 = new Mock<IPokemon>();
|
||||
var pokemon3 = new Mock<IPokemon>();
|
||||
var pokemon4 = new Mock<IPokemon>();
|
||||
var pokemon1 = Substitute.For<IPokemon>();
|
||||
var pokemon2 = Substitute.For<IPokemon>();
|
||||
var pokemon3 = Substitute.For<IPokemon>();
|
||||
var pokemon4 = Substitute.For<IPokemon>();
|
||||
|
||||
var choice1 = new Mock<ITurnChoice>();
|
||||
choice1.Setup(c => c.User).Returns(pokemon1.Object);
|
||||
var choice2 = new Mock<ITurnChoice>();
|
||||
choice2.Setup(c => c.User).Returns(pokemon2.Object);
|
||||
var choice3 = new Mock<ITurnChoice>();
|
||||
choice3.Setup(c => c.User).Returns(pokemon3.Object);
|
||||
var choice4 = new Mock<ITurnChoice>();
|
||||
choice4.Setup(c => c.User).Returns(pokemon4.Object);
|
||||
var choice1 = Substitute.For<ITurnChoice>();
|
||||
choice1.User.Returns(pokemon1);
|
||||
var choice2 = Substitute.For<ITurnChoice>();
|
||||
choice2.User.Returns(pokemon2);
|
||||
var choice3 = Substitute.For<ITurnChoice>();
|
||||
choice3.User.Returns(pokemon3);
|
||||
var choice4 = Substitute.For<ITurnChoice>();
|
||||
choice4.User.Returns(pokemon4);
|
||||
|
||||
var queue = new BattleChoiceQueue([choice1.Object, choice2.Object, choice3.Object, choice4.Object]);
|
||||
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
|
||||
queue.Dequeue();
|
||||
var result = queue.MovePokemonChoiceNext(pokemon1.Object);
|
||||
var result = queue.MovePokemonChoiceNext(pokemon1);
|
||||
await Assert.That(result).IsFalse();
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ChoiceQueue_MovePokemonChoiceLast()
|
||||
{
|
||||
var pokemon1 = new Mock<IPokemon>();
|
||||
var pokemon2 = new Mock<IPokemon>();
|
||||
var pokemon3 = new Mock<IPokemon>();
|
||||
var pokemon4 = new Mock<IPokemon>();
|
||||
var pokemon1 = Substitute.For<IPokemon>();
|
||||
var pokemon2 = Substitute.For<IPokemon>();
|
||||
var pokemon3 = Substitute.For<IPokemon>();
|
||||
var pokemon4 = Substitute.For<IPokemon>();
|
||||
|
||||
var choice1 = new Mock<ITurnChoice>();
|
||||
choice1.Setup(c => c.User).Returns(pokemon1.Object);
|
||||
var choice2 = new Mock<ITurnChoice>();
|
||||
choice2.Setup(c => c.User).Returns(pokemon2.Object);
|
||||
var choice3 = new Mock<ITurnChoice>();
|
||||
choice3.Setup(c => c.User).Returns(pokemon3.Object);
|
||||
var choice4 = new Mock<ITurnChoice>();
|
||||
choice4.Setup(c => c.User).Returns(pokemon4.Object);
|
||||
var choice1 = Substitute.For<ITurnChoice>();
|
||||
choice1.User.Returns(pokemon1);
|
||||
var choice2 = Substitute.For<ITurnChoice>();
|
||||
choice2.User.Returns(pokemon2);
|
||||
var choice3 = Substitute.For<ITurnChoice>();
|
||||
choice3.User.Returns(pokemon3);
|
||||
var choice4 = Substitute.For<ITurnChoice>();
|
||||
choice4.User.Returns(pokemon4);
|
||||
|
||||
var queue = new BattleChoiceQueue([choice1.Object, choice2.Object, choice3.Object, choice4.Object]);
|
||||
var result = queue.MovePokemonChoiceLast(pokemon2.Object);
|
||||
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
|
||||
var result = queue.MovePokemonChoiceLast(pokemon2);
|
||||
await Assert.That(result).IsTrue();
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice1.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice4.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice1);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice4);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ChoiceQueue_MovePokemonChoiceLastFailsIfAlreadyExecuted()
|
||||
{
|
||||
var pokemon1 = new Mock<IPokemon>();
|
||||
var pokemon2 = new Mock<IPokemon>();
|
||||
var pokemon3 = new Mock<IPokemon>();
|
||||
var pokemon4 = new Mock<IPokemon>();
|
||||
var pokemon1 = Substitute.For<IPokemon>();
|
||||
var pokemon2 = Substitute.For<IPokemon>();
|
||||
var pokemon3 = Substitute.For<IPokemon>();
|
||||
var pokemon4 = Substitute.For<IPokemon>();
|
||||
|
||||
var choice1 = new Mock<ITurnChoice>();
|
||||
choice1.Setup(c => c.User).Returns(pokemon1.Object);
|
||||
var choice2 = new Mock<ITurnChoice>();
|
||||
choice2.Setup(c => c.User).Returns(pokemon2.Object);
|
||||
var choice3 = new Mock<ITurnChoice>();
|
||||
choice3.Setup(c => c.User).Returns(pokemon3.Object);
|
||||
var choice4 = new Mock<ITurnChoice>();
|
||||
choice4.Setup(c => c.User).Returns(pokemon4.Object);
|
||||
var choice1 = Substitute.For<ITurnChoice>();
|
||||
choice1.User.Returns(pokemon1);
|
||||
var choice2 = Substitute.For<ITurnChoice>();
|
||||
choice2.User.Returns(pokemon2);
|
||||
var choice3 = Substitute.For<ITurnChoice>();
|
||||
choice3.User.Returns(pokemon3);
|
||||
var choice4 = Substitute.For<ITurnChoice>();
|
||||
choice4.User.Returns(pokemon4);
|
||||
|
||||
var queue = new BattleChoiceQueue([choice1.Object, choice2.Object, choice3.Object, choice4.Object]);
|
||||
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
|
||||
queue.Dequeue();
|
||||
var result = queue.MovePokemonChoiceLast(pokemon1.Object);
|
||||
var result = queue.MovePokemonChoiceLast(pokemon1);
|
||||
await Assert.That(result).IsFalse();
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice4.Object);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
|
||||
await Assert.That(queue.Dequeue()).IsEqualTo(choice4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user