Tweaks for JSON loading, minor refactor of unit tests
This commit is contained in:
@@ -3614,6 +3614,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
// Done up to here
|
||||
{
|
||||
"name": "fire_spin",
|
||||
"type": "fire",
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static.Moves;
|
||||
using PkmnLib.Tests.Integration;
|
||||
|
||||
namespace PkmnLib.Tests.DataTests;
|
||||
|
||||
public class MoveDataTests
|
||||
{
|
||||
[Test]
|
||||
public async Task AllMoveEffectsHaveValidScripts()
|
||||
public record TestCaseData(IDynamicLibrary Library, IMoveData Move)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Move.Name + " has valid scripts";
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> AllMovesHaveValidScriptsData()
|
||||
{
|
||||
var library = LibraryHelpers.LoadLibrary();
|
||||
var moveLibrary = library.StaticLibrary.Moves;
|
||||
@@ -14,17 +24,26 @@ public class MoveDataTests
|
||||
{
|
||||
if (move.SecondaryEffect == null)
|
||||
continue;
|
||||
var scriptName = move.SecondaryEffect.Name;
|
||||
yield return new TestCaseData(library, move);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[MethodDataSource(nameof(AllMovesHaveValidScriptsData))]
|
||||
public async Task AllMoveEffectsHaveValidScripts(TestCaseData test)
|
||||
{
|
||||
if (test.Move.SecondaryEffect == null)
|
||||
return;
|
||||
var scriptName = test.Move.SecondaryEffect.Name;
|
||||
|
||||
try
|
||||
{
|
||||
await Assert.That(library.ScriptResolver.TryResolve(ScriptCategory.Move, scriptName,
|
||||
move.SecondaryEffect.Parameters, out var script)).IsTrue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AggregateException($"Failed to resolve script for move {move.Name} with effect {scriptName}", e);
|
||||
}
|
||||
try
|
||||
{
|
||||
await Assert.That(test.Library.ScriptResolver.TryResolve(ScriptCategory.Move, scriptName,
|
||||
test.Move.SecondaryEffect.Parameters, out var script)).IsTrue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AggregateException($"Failed to resolve script for move {test.Move.Name} with effect {scriptName}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ public class IntegrationTestRunner
|
||||
var serializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
AllowTrailingCommas = true,
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
};
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,12 @@ public class IntegrationTestModel
|
||||
public string Description { get; set; } = null!;
|
||||
public IntegrationTestBattleSetup BattleSetup { get; set; } = null!;
|
||||
public IntegrationTestAction[] Actions { get; set; } = null!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public class IntegrationTestBattleSetup
|
||||
|
||||
Reference in New Issue
Block a user