Fixes some warnings from unit tests

This commit is contained in:
2025-05-02 15:53:49 +02:00
parent 068ff8d5b7
commit dabb26e4f2
9 changed files with 16 additions and 24 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections;
using System.Text.Json;
using EnumerableAsyncProcessor.Extensions;
using PkmnLib.Dynamic.Models;
@@ -9,7 +8,7 @@ namespace PkmnLib.Tests.Integration;
public class IntegrationTestRunner
{
public static IEnumerable<IntegrationTestModel> TestCases()
public static IEnumerable<Func<IntegrationTestModel>> TestCases()
{
var files = Directory.GetFiles("Integration/Tests", "*.json");
var serializerOptions = new JsonSerializerOptions
@@ -20,9 +19,11 @@ public class IntegrationTestRunner
};
foreach (var file in files)
{
var json = File.ReadAllText(file);
var test = JsonSerializer.Deserialize<IntegrationTestModel>(json, serializerOptions)!;
yield return test;
yield return () =>
{
var json = File.ReadAllText(file);
return JsonSerializer.Deserialize<IntegrationTestModel>(json, serializerOptions)!;
};
}
}

View File

@@ -38,9 +38,9 @@ public class SetMoveChoiceAction : IntegrationTestAction
{
var user = battle.Sides[Place[0]].Pokemon[Place[1]];
await Assert.That(user).IsNotNull();
var move = user.Moves.First(m => m?.MoveData.Name == Move);
var move = user!.Moves.First(m => m?.MoveData.Name == Move);
await Assert.That(move).IsNotNull();
var res = battle.TrySetChoice(new MoveChoice(user, move, Target[0], Target[1]));
var res = battle.TrySetChoice(new MoveChoice(user, move!, Target[0], Target[1]));
await Assert.That(res).IsTrue();
}
}
@@ -54,7 +54,7 @@ public class SetPassChoiceAction : IntegrationTestAction
{
var user = battle.Sides[Place[0]].Pokemon[Place[1]];
await Assert.That(user).IsNotNull();
var res = battle.TrySetChoice(new PassChoice(user));
var res = battle.TrySetChoice(new PassChoice(user!));
await Assert.That(res).IsTrue();
}
}