106 lines
4.1 KiB
C#
106 lines
4.1 KiB
C#
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Dynamic.Models.Choices;
|
|
|
|
namespace PkmnLib.Tests.Dynamic;
|
|
|
|
public class ChoiceQueueTests
|
|
{
|
|
[Test]
|
|
public async Task ChoiceQueue_MovePokemonChoiceNext()
|
|
{
|
|
var pokemon1 = Substitute.For<IPokemon>();
|
|
var pokemon2 = Substitute.For<IPokemon>();
|
|
var pokemon3 = Substitute.For<IPokemon>();
|
|
var pokemon4 = Substitute.For<IPokemon>();
|
|
|
|
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, choice2, choice3, choice4]);
|
|
var result = queue.MovePokemonChoiceNext(pokemon3);
|
|
await Assert.That(result).IsTrue();
|
|
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ChoiceQueue_MovePokemonChoiceNextFailsIfAlreadyExecuted()
|
|
{
|
|
var pokemon1 = Substitute.For<IPokemon>();
|
|
var pokemon2 = Substitute.For<IPokemon>();
|
|
var pokemon3 = Substitute.For<IPokemon>();
|
|
var pokemon4 = Substitute.For<IPokemon>();
|
|
|
|
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, choice2, choice3, choice4]);
|
|
queue.Dequeue();
|
|
var result = queue.MovePokemonChoiceNext(pokemon1);
|
|
await Assert.That(result).IsFalse();
|
|
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ChoiceQueue_MovePokemonChoiceLast()
|
|
{
|
|
var pokemon1 = Substitute.For<IPokemon>();
|
|
var pokemon2 = Substitute.For<IPokemon>();
|
|
var pokemon3 = Substitute.For<IPokemon>();
|
|
var pokemon4 = Substitute.For<IPokemon>();
|
|
|
|
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, choice2, choice3, choice4]);
|
|
var result = queue.MovePokemonChoiceLast(pokemon2);
|
|
await Assert.That(result).IsTrue();
|
|
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 = Substitute.For<IPokemon>();
|
|
var pokemon2 = Substitute.For<IPokemon>();
|
|
var pokemon3 = Substitute.For<IPokemon>();
|
|
var pokemon4 = Substitute.For<IPokemon>();
|
|
|
|
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, choice2, choice3, choice4]);
|
|
queue.Dequeue();
|
|
var result = queue.MovePokemonChoiceLast(pokemon1);
|
|
await Assert.That(result).IsFalse();
|
|
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
|
|
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
|
|
await Assert.That(queue.Dequeue()).IsEqualTo(choice4);
|
|
}
|
|
} |