This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for the <see cref="FlyingPress"/> script, which implements Flying Press.
|
||||
/// Behavior is verified against the Bulbapedia page for Flying Press (Generation VII).
|
||||
/// </summary>
|
||||
public class FlyingPressTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a fully mocked test setup for Flying Press tests, with a type library containing both the
|
||||
/// Fighting and Flying types.
|
||||
/// </summary>
|
||||
private static (FlyingPress flyingPress, IExecutingMove move, IPokemon 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<IExecutingMove>();
|
||||
move.User.Library.StaticLibrary.Types.Returns(typeLibrary);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
return (flyingPress, move, target, fighting, flying);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeTypesForMove_FlyingTypeAvailable_AddsFlyingTypeToMoveTypes()
|
||||
{
|
||||
// Arrange
|
||||
var (flyingPress, move, target, fighting, flying) = CreateTestSetup();
|
||||
IList<TypeIdentifier> types = new List<TypeIdentifier> { fighting };
|
||||
|
||||
// Act
|
||||
flyingPress.ChangeTypesForMove(move, target, 0, types);
|
||||
|
||||
// Assert
|
||||
await Assert.That(types.Contains(flying)).IsTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeTypesForMove_FlyingTypeAvailable_KeepsOriginalFightingType()
|
||||
{
|
||||
// Arrange
|
||||
var (flyingPress, move, target, fighting, _) = CreateTestSetup();
|
||||
IList<TypeIdentifier> types = new List<TypeIdentifier> { 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[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<IExecutingMove>();
|
||||
move.User.Library.StaticLibrary.Types.Returns(typeLibrary);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
IList<TypeIdentifier> types = new List<TypeIdentifier> { fighting };
|
||||
|
||||
// Act
|
||||
flyingPress.ChangeTypesForMove(move, target, 0, types);
|
||||
|
||||
// Assert
|
||||
await Assert.That(types.Count).IsEqualTo(1);
|
||||
await Assert.That(types[0]).IsEqualTo(fighting);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user