Update TUnit, warning cleanup
Some checks failed
Build / Build (push) Failing after 35s

This commit is contained in:
2026-07-05 13:24:22 +02:00
parent 16a1990486
commit cc091d5327
61 changed files with 113 additions and 190 deletions

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static.Libraries;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static.Libraries;
namespace PkmnLib.Tests.Dataloader;
@@ -70,9 +69,9 @@ public class SpeciesDataloaderTests
await Assert.That(species).IsNotNull();
await Assert.That(species!.TryGetForm("arceus_fighting", out var form)).IsTrue();
await Assert.That(form).IsNotNull();
await Assert.That(form!.Types).HasCount().EqualTo(1);
await Assert.That(form.Types[0].Name).IsEqualTo("fighting");
await Assert.That(form.Flags).IsEqualTo(species.GetDefaultForm().Flags);
await Assert.That(form!.Types).Count().IsEqualTo(1);
await Assert.That(form.Types[0].Name.ToString()).IsEqualTo("fighting");
await Assert.That(form.Flags).IsEquivalentTo(species.GetDefaultForm().Flags);
await Assert.That(form.BaseStats).IsEqualTo(species.GetDefaultForm().BaseStats);
}
}

View File

@@ -1,6 +1,5 @@
using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Tests.Dataloader;

View File

@@ -21,8 +21,8 @@ public class ChoiceQueueTests
choice2.Speed.Returns((uint)50);
var queue = new BattleChoiceQueue([choice1, choice2]);
await Assert.That(queue.Dequeue()).IsEqualTo(choice1);
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice1);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice2);
}
[Test]
@@ -41,8 +41,8 @@ public class ChoiceQueueTests
choice2.Speed.Returns((uint)50);
var queue = new BattleChoiceQueue([choice1, choice2]);
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
await Assert.That(queue.Dequeue()).IsEqualTo(choice1);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice2);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice1);
}
[Test]
@@ -69,7 +69,7 @@ public class ChoiceQueueTests
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
var result = queue.MovePokemonChoiceNext(pokemon3);
await Assert.That(result).IsTrue();
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice3);
}
[Test]
@@ -97,7 +97,7 @@ public class ChoiceQueueTests
queue.Dequeue();
var result = queue.MovePokemonChoiceNext(pokemon1);
await Assert.That(result).IsFalse();
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice2);
}
[Test]
@@ -124,10 +124,10 @@ public class ChoiceQueueTests
var queue = new BattleChoiceQueue([choice1, choice2, choice3, choice4]);
var result = queue.MovePokemonChoiceLast(pokemon2);
await Assert.That(result).IsTrue();
await Assert.That(queue.Dequeue()).IsEqualTo(choice1);
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
await Assert.That(queue.Dequeue()).IsEqualTo(choice4);
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice1);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice3);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice4);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice2);
}
[Test]
@@ -155,8 +155,8 @@ public class ChoiceQueueTests
queue.Dequeue();
var result = queue.MovePokemonChoiceLast(pokemon1);
await Assert.That(result).IsFalse();
await Assert.That(queue.Dequeue()).IsEqualTo(choice2);
await Assert.That(queue.Dequeue()).IsEqualTo(choice3);
await Assert.That(queue.Dequeue()).IsEqualTo(choice4);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice2);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice3);
await Assert.That((IMoveChoice)queue.Dequeue()!).IsEqualTo(choice4);
}
}

View File

@@ -1,4 +1,3 @@
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Dynamic.Models;
using PkmnLib.Static;
using PkmnLib.Static.Species;
@@ -13,7 +12,7 @@ public class PokemonStatBoostTests
var library = LibraryHelpers.LoadLibrary();
if (!library.StaticLibrary.Species.TryGet("bulbasaur", out var species))
throw new InvalidOperationException("Failed to load bulbasaur species.");
return new PokemonImpl(library, species!, species!.GetDefaultForm(), new AbilityIndex
return new PokemonImpl(library, species, species.GetDefaultForm(), new AbilityIndex
{
Index = 0,
IsHidden = false,

View File

@@ -32,10 +32,10 @@ public class SerializationTests
await Assert.That(data.Gender).IsEqualTo(Gender.Male);
await Assert.That(data.Coloring).IsEqualTo((byte)0);
await Assert.That(data.HeldItem).IsNull();
await Assert.That(data.CurrentHealth).IsEqualTo((ushort)29);
await Assert.That(data.CurrentHealth).IsEqualTo((uint)29);
await Assert.That(data.Happiness).IsEqualTo((byte)70);
await Assert.That(data.Moves).HasCount().EqualTo(4);
await Assert.That(data.Moves).Count().IsEqualTo(4);
await Assert.That(data.Moves[0]).IsNotNull();
await Assert.That(data.Moves[0]!.MoveName).IsEqualTo("tackle");
await Assert.That(data.Moves[0]!.LearnMethod).IsEqualTo(MoveLearnMethod.LevelUp);
@@ -93,7 +93,7 @@ public class SerializationTests
await Assert.That(pokemon.EffortValues).IsEqualTo(new EffortValueStatisticSet(0, 0, 0, 0, 0, 0));
await Assert.That(pokemon.Nature.Name.ToString()).IsEqualTo("hardy");
await Assert.That(pokemon.Nickname).IsEqualTo("foo");
await Assert.That(pokemon.Moves).HasCount().EqualTo(4);
await Assert.That(pokemon.Moves).Count().IsEqualTo(4);
await Assert.That(pokemon.Moves[0]).IsNotNull();
await Assert.That(pokemon.Moves[0]!.MoveData.Name.ToString()).IsEqualTo("tackle");
await Assert.That(pokemon.Moves[0]!.LearnMethod).IsEqualTo(MoveLearnMethod.LevelUp);
@@ -153,7 +153,7 @@ public class SerializationTests
await Assert.That(deserialized.Nature).IsEqualTo("hardy");
await Assert.That(deserialized.Nickname).IsEqualTo("foo");
await Assert.That(deserialized.Moves).HasCount().EqualTo(4);
await Assert.That(deserialized.Moves).Count().IsEqualTo(4);
await Assert.That(deserialized.Moves[0]).IsNotNull();
await Assert.That(deserialized.Moves[0]!.MoveName).IsEqualTo("tackle");
await Assert.That(deserialized.Moves[0]!.LearnMethod).IsEqualTo(MoveLearnMethod.LevelUp);

View File

@@ -58,7 +58,7 @@ public class IntegrationTestRunner
}
await TestContext.Current!.OutputWriter.WriteLineAsync("File: " + $"file://{test.FileName}");
TestContext.Current.AddArtifact(new Artifact
TestContext.Current.Output.AttachArtifact(new Artifact
{
File = new FileInfo(test.FileName),
DisplayName = test.Name,

View File

@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Pcg;
using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
using PkmnLib.Static.Species;
@@ -60,7 +59,7 @@ public class DeepCloneTests
var clonePrivateValue =
clone.GetType().GetProperty("PrivateValue", BindingFlags.NonPublic | BindingFlags.Instance)!
.GetValue(clone);
await Assert.That(clonePrivateValue).IsEqualTo(1);
await Assert.That((int)clonePrivateValue!).IsEqualTo(1);
}
[Test]
@@ -72,7 +71,7 @@ public class DeepCloneTests
await Assert.That(clone).IsNotEqualTo(obj);
var clonePrivateField =
clone.GetType().GetField("_privateField", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(clone);
await Assert.That(clonePrivateField).IsEqualTo(1);
await Assert.That((int)clonePrivateField!).IsEqualTo(1);
}
[Test]
@@ -119,8 +118,8 @@ public class DeepCloneTests
var clone = battle.DeepClone();
await Assert.That(clone).IsNotEqualTo(battle);
await Assert.That(clone.Sides[0].Pokemon[0]).IsNotEqualTo(battle.Sides[0].Pokemon[0]);
await Assert.That(clone.Sides[1].Pokemon[0]).IsNotEqualTo(battle.Sides[1].Pokemon[0]);
await Assert.That(clone.Sides[0].Pokemon[0]).IsNotEqualTo(battle.Sides[0].Pokemon[0]!);
await Assert.That(clone.Sides[1].Pokemon[0]).IsNotEqualTo(battle.Sides[1].Pokemon[0]!);
await Assert.That(clone.Sides[0].Pokemon[0]!.Species).IsEqualTo(battle.Sides[0].Pokemon[0]!.Species);
await Assert.That(clone.Sides[1].Pokemon[0]!.Species).IsEqualTo(battle.Sides[1].Pokemon[0]!.Species);
@@ -129,21 +128,21 @@ public class DeepCloneTests
var pokemon = clone.Sides[0].Pokemon[0]!;
await Assert.That(pokemon).IsNotNull();
await Assert.That(pokemon).IsNotEqualTo(battle.Sides[0].Pokemon[0]);
await Assert.That(pokemon).IsNotEqualTo(battle.Sides[0].Pokemon[0]!);
await Assert.That(pokemon.BattleData).IsNotNull();
await Assert.That(pokemon.BattleData).IsNotEqualTo(battle.Sides[0].Pokemon[0]!.BattleData);
await Assert.That(pokemon.BattleData!.Battle).IsEqualTo(clone);
await Assert.That(pokemon.BattleData).IsNotEqualTo(battle.Sides[0].Pokemon[0]!.BattleData!);
await Assert.That(pokemon.BattleData!.Battle).IsEqualTo((IBattle)clone);
await Assert.That(pokemon.BattleData!.SeenOpponents).Contains(clone.Sides[1].Pokemon[0]!);
await Assert.That(pokemon.BattleData!.SeenOpponents).DoesNotContain(battle.Sides[1].Pokemon[0]!);
await Assert.That(pokemon.StatBoost.Defense).IsEqualTo((sbyte)2);
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNotNull();
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNotEqualTo(
battle.Sides[0].Pokemon[0]!.Volatile.Get<ChargeBounceEffect>());
battle.Sides[0].Pokemon[0]!.Volatile.Get<ChargeBounceEffect>()!);
var ownerGetter =
typeof(ChargeBounceEffect).GetField("_owner", BindingFlags.NonPublic | BindingFlags.Instance)!;
var owner = ownerGetter.GetValue(pokemon.Volatile.Get<ChargeBounceEffect>()!);
await Assert.That(owner).IsEqualTo(pokemon);
await Assert.That((IPokemon)owner!).IsEqualTo(pokemon);
pokemon.Volatile.Remove<ChargeBounceEffect>();
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNull();

View File

@@ -1,5 +1,4 @@
using PkmnLib.Static;
using TUnit.Assertions.AssertConditions.Throws;
namespace PkmnLib.Tests.Static;