Migrate to TUnit for unit tests
This commit is contained in:
@@ -14,7 +14,7 @@ namespace PkmnLib.Tests.Integration.Models;
|
||||
[JsonDerivedType(typeof(AssertAction), "assert")]
|
||||
public abstract class IntegrationTestAction
|
||||
{
|
||||
public abstract void Execute(IBattle battle);
|
||||
public abstract Task Execute(IBattle battle);
|
||||
}
|
||||
|
||||
public class SetPokemonAction : IntegrationTestAction
|
||||
@@ -22,10 +22,11 @@ public class SetPokemonAction : IntegrationTestAction
|
||||
public List<byte> Place { get; set; } = null!;
|
||||
public List<byte> FromParty { get; set; } = null!;
|
||||
|
||||
public override void Execute(IBattle battle)
|
||||
public override Task Execute(IBattle battle)
|
||||
{
|
||||
var mon = battle.Parties[FromParty[0]].Party[FromParty[1]];
|
||||
battle.Sides[Place[0]].SwapPokemon(Place[1], mon);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +38,14 @@ public class SetMoveChoiceAction : IntegrationTestAction
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Execute(IBattle battle)
|
||||
public override async Task Execute(IBattle battle)
|
||||
{
|
||||
var user = battle.Sides[Place[0]].Pokemon[Place[1]];
|
||||
Assert.That(user, Is.Not.Null);
|
||||
await Assert.That(user).IsNotNull();
|
||||
var move = user.Moves.First(m => m?.MoveData.Name == Move);
|
||||
Assert.That(move, Is.Not.Null);
|
||||
await Assert.That(move).IsNotNull();
|
||||
var res = battle.TrySetChoice(new MoveChoice(user, move, Target[0], Target[1]));
|
||||
Assert.That(res, Is.True);
|
||||
await Assert.That(res).IsTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +54,12 @@ public class SetPassChoiceAction : IntegrationTestAction
|
||||
public List<byte> Place { get; set; } = null!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Execute(IBattle battle)
|
||||
public override async Task Execute(IBattle battle)
|
||||
{
|
||||
var user = battle.Sides[Place[0]].Pokemon[Place[1]];
|
||||
Assert.That(user, Is.Not.Null);
|
||||
await Assert.That(user).IsNotNull();
|
||||
var res = battle.TrySetChoice(new PassChoice(user));
|
||||
Assert.That(res, Is.True);
|
||||
await Assert.That(res).IsTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,12 +69,12 @@ public class AssertAction : IntegrationTestAction
|
||||
public JsonNode Expected { get; set; } = null!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Execute(IBattle battle)
|
||||
public override async Task Execute(IBattle battle)
|
||||
{
|
||||
var list = battle.Path(Value).ToList();
|
||||
var value = list.Count == 1 ? list[0] : list;
|
||||
|
||||
var serialized = JsonSerializer.Serialize(value);
|
||||
Assert.That(serialized, Is.EqualTo(Expected.ToJsonString()));
|
||||
await Assert.That(serialized).IsEqualTo(Expected.ToJsonString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user