using PkmnLib.Dynamic.Models; using PkmnLib.Plugin.Gen7.Scripts.Moves; using PkmnLib.Static; using PkmnLib.Static.Libraries; namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves; /// /// Tests for the script, which implements Flying Press. /// Behavior is verified against the Bulbapedia page for Flying Press (Generation VII). /// public class FlyingPressTests { /// /// Creates a fully mocked test setup for Flying Press tests, with a type library containing both the /// Fighting and Flying types. /// private static (FlyingPress flyingPress, IExecutingMove move, IBattlePokemon target, TypeIdentifier fighting, TypeIdentifier flying) CreateTestSetup() { var flyingPress = new FlyingPress(); var typeLibrary = new TypeLibrary(); var fighting = typeLibrary.RegisterType("fighting"); var flying = typeLibrary.RegisterType("flying"); var move = Substitute.For(); move.User.Library.StaticLibrary.Types.Returns(typeLibrary); var target = Substitute.For(); return (flyingPress, move, target, fighting, flying); } /// /// Bulbapedia: "Despite being a Fighting move, the damage dealt is actually a combination of Fighting and /// Flying types, and thus its effectiveness against a given Pokémon differs from other Fighting-type moves." /// The script adds the Flying type to the list of types used for the move's effectiveness calculation. /// [Test] public async Task ChangeTypesForMove_FlyingTypeAvailable_AddsFlyingTypeToMoveTypes() { // Arrange var (flyingPress, move, target, fighting, flying) = CreateTestSetup(); IList types = new List { fighting }; // Act flyingPress.ChangeTypesForMove(move, target, 0, types); // Assert await Assert.That(types.Contains(flying)).IsTrue(); } /// /// Bulbapedia: "However, for all other purposes, it is a Fighting-type move: only Fighting-type Pokémon can /// receive the same-type attack bonus on Flying Press". /// The Flying type is added on top of the move's own Fighting type; the original type is not replaced. /// [Test] public async Task ChangeTypesForMove_FlyingTypeAvailable_KeepsOriginalFightingType() { // Arrange var (flyingPress, move, target, fighting, _) = CreateTestSetup(); IList types = new List { fighting }; // Act flyingPress.ChangeTypesForMove(move, target, 0, types); // Assert - the Fighting type is still the first type, and exactly one type was added await Assert.That(types[0]).IsEqualTo(fighting); await Assert.That(types.Count).IsEqualTo(2); } /// /// Bulbapedia: "the damage dealt is actually a combination of Fighting and Flying types". /// Technical test: if the type library does not know a "flying" type, the script leaves the move's types /// unchanged instead of adding a default type identifier. /// [Test] public async Task ChangeTypesForMove_FlyingTypeMissingFromLibrary_TypesUnchanged() { // Arrange var flyingPress = new FlyingPress(); var typeLibrary = new TypeLibrary(); var fighting = typeLibrary.RegisterType("fighting"); var move = Substitute.For(); move.User.Library.StaticLibrary.Types.Returns(typeLibrary); var target = Substitute.For(); IList types = new List { fighting }; // Act flyingPress.ChangeTypesForMove(move, target, 0, types); // Assert await Assert.That(types.Count).IsEqualTo(1); await Assert.That(types[0]).IsEqualTo(fighting); } }