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);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
global using TUnit;
|
||||
global using NSubstitute;
|
||||
global using FluentAssertions;
|
||||
global using LevelInt = byte;
|
||||
@@ -10,12 +10,19 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.20.70"/>
|
||||
<PackageReference Include="CSPath" Version="0.0.4"/>
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||
<PackageReference Include="FluentAssertions" Version="8.2.0"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NSubstitute" Version="5.3.0"/>
|
||||
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
|
||||
<PackageReference Include="TUnit" Version="0.5.18"/>
|
||||
<PackageReference Include="TUnit" Version="0.19.116"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user