Implements critical capture, tweaks for integration tests.
All checks were successful
Build / Build (push) Successful in 48s

This commit is contained in:
2025-05-18 17:07:46 +02:00
parent cbd4340b13
commit 377c1a1c68
11 changed files with 158 additions and 52 deletions

View File

@@ -3,6 +3,7 @@ using System.Text.Json.Serialization;
using CSPath;
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.Models.Choices;
using TUnit.Core.Logging;
using JsonSerializer = System.Text.Json.JsonSerializer;
namespace PkmnLib.Tests.Integration.Models;
@@ -23,6 +24,7 @@ public class SetPokemonAction : IntegrationTestAction
{
var mon = battle.Parties[FromParty[0]].Party[FromParty[1]];
battle.Sides[Place[0]].SwapPokemon(Place[1], mon);
Console.WriteLine($"Set: {mon} to place {Place[0]}:{Place[1]}");
return Task.CompletedTask;
}
}
@@ -42,6 +44,8 @@ public class SetMoveChoiceAction : IntegrationTestAction
await Assert.That(move).IsNotNull();
var res = battle.TrySetChoice(new MoveChoice(user, move!, Target[0], Target[1]));
await Assert.That(res).IsTrue();
var target = battle.Sides[Target[0]].Pokemon[Target[1]];
Console.WriteLine($"Choice: {user} used {move} on {target} ({Target[0]}:{Target[1]})");
}
}
@@ -56,13 +60,14 @@ public class SetPassChoiceAction : IntegrationTestAction
await Assert.That(user).IsNotNull();
var res = battle.TrySetChoice(new PassChoice(user!));
await Assert.That(res).IsTrue();
Console.WriteLine($"Choice: {user} Pass");
}
}
public class AssertAction : IntegrationTestAction
{
public string Value { get; set; } = null!;
public JsonNode Expected { get; set; } = null!;
public string Value { get; init; } = null!;
public JsonNode Expected { get; init; } = null!;
/// <inheritdoc />
public override async Task Execute(IBattle battle)
@@ -71,6 +76,9 @@ public class AssertAction : IntegrationTestAction
var value = list.Count == 1 ? list[0] : list;
var serialized = JsonSerializer.Serialize(value);
await Assert.That(serialized).IsEqualTo(Expected.ToJsonString());
#pragma warning disable TUnitAssertions0003
await Assert.That(serialized, Value).IsEqualTo(Expected.ToJsonString());
#pragma warning restore TUnitAssertions0003
Console.WriteLine($"Assert: {Value} = {serialized}");
}
}