Fixes some warnings from unit tests
This commit is contained in:
parent
068ff8d5b7
commit
dabb26e4f2
@ -13,7 +13,7 @@ public class MoveDataTests
|
||||
public override string ToString() => Move.Name + " has valid scripts";
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> AllMovesHaveValidScriptsData()
|
||||
public static IEnumerable<Func<TestCaseData>> AllMovesHaveValidScriptsData()
|
||||
{
|
||||
var library = LibraryHelpers.LoadLibrary();
|
||||
var moveLibrary = library.StaticLibrary.Moves;
|
||||
@ -21,7 +21,7 @@ public class MoveDataTests
|
||||
{
|
||||
if (move.SecondaryEffect == null)
|
||||
continue;
|
||||
yield return new TestCaseData(library, move);
|
||||
yield return () => new TestCaseData(library, move);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ public class AbilityDataLoaderTests
|
||||
[Test]
|
||||
public async Task TestPrimaryAbilityFile()
|
||||
{
|
||||
using var stream = File.OpenRead("Data/Abilities.json");
|
||||
await using var stream = File.OpenRead("Data/Abilities.json");
|
||||
var library = AbilityDataLoader.LoadAbilities(stream);
|
||||
await Assert.That(library).IsNotNull();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class GrowthRateDataLoaderTests
|
||||
[Test]
|
||||
public async Task TestPrimaryGrowthRateFile()
|
||||
{
|
||||
using var file = File.Open("Data/GrowthRates.json", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await using var file = File.Open("Data/GrowthRates.json", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
var library = GrowthRateDataLoader.LoadGrowthRates(file);
|
||||
await Assert.That(library).IsNotNull();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class ItemDataLoaderTests
|
||||
[Test]
|
||||
public async Task TestPrimaryItemFile()
|
||||
{
|
||||
using var stream = File.OpenRead("Data/Items.json");
|
||||
await using var stream = File.OpenRead("Data/Items.json");
|
||||
var library = ItemDataLoader.LoadItems(stream);
|
||||
await Assert.That(library).IsNotNull();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class NatureDataloaderTests
|
||||
[Test]
|
||||
public async Task TestPrimaryNatureFile()
|
||||
{
|
||||
using var file = File.Open("Data/Natures.csv", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await using var file = File.Open("Data/Natures.csv", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
var library = NatureDataLoader.LoadNatureLibrary(file);
|
||||
await Assert.That(library).IsNotNull();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class SpeciesDataloaderTests
|
||||
[Test]
|
||||
public async Task TestPrimarySpeciesFile()
|
||||
{
|
||||
using var file = File.Open("Data/Pokemon.json", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await using var file = File.Open("Data/Pokemon.json", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
var typeLibrary = new TypeLibrary();
|
||||
typeLibrary.RegisterType("Normal");
|
||||
typeLibrary.RegisterType("Fire");
|
||||
|
@ -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
|
||||
@ -19,10 +18,12 @@ public class IntegrationTestRunner
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
};
|
||||
foreach (var file in files)
|
||||
{
|
||||
yield return () =>
|
||||
{
|
||||
var json = File.ReadAllText(file);
|
||||
var test = JsonSerializer.Deserialize<IntegrationTestModel>(json, serializerOptions)!;
|
||||
yield return test;
|
||||
return JsonSerializer.Deserialize<IntegrationTestModel>(json, serializerOptions)!;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Tests;
|
||||
|
||||
public class BattleStatCalculatorTests
|
||||
{
|
||||
[Test]
|
||||
public async Task Test1()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user