PKHeX/Tests/PKHeX.Core.Tests/Legality/BreedTests.cs
Kurt 88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.

Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.

Adds functionality for Batch Editor commands to `>`, `<` and <=/>=

TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.

Main window has a new layout to account for DPI scaling (8 point grid)

Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691)
Added: Properties for ribbon/mark count (closes #3659)
Fixed: Traded SV eggs are now checked correctly (closes #3692)
2023-01-21 20:02:33 -08:00

92 lines
4.1 KiB
C#

using System;
using System.Linq;
using FluentAssertions;
using Xunit;
using static PKHeX.Core.Move;
using static PKHeX.Core.Species;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core.Tests.Legality;
public class BreedTests
{
private const int MovesetCount = 4; // Four moves; zeroed empty slots.
private static void GetMoves(Span<Move> moves, Span<ushort> result)
{
for (int i = 0; i < moves.Length; i++)
result[i] = (ushort) moves[i];
}
[Theory]
[InlineData(GD, Bulbasaur, 0, Tackle, Growl)]
[InlineData(SI, Igglybuff, 0, FeintAttack, Pound, Curse, ZapCannon)]
[InlineData( C, Igglybuff, 0, FeintAttack, Pound, Flamethrower, Sing)]
[InlineData( B, Heracross, 0, Megahorn, NightSlash, CloseCombat, StoneEdge)]
[InlineData( B, Heracross, 0, Bide, Megahorn, Counter, Reversal)]
[InlineData( B, Heracross, 0, HornAttack, Endure, Megahorn, TakeDown)]
[InlineData( B, Heracross, 0, Endure, Megahorn, FocusPunch, Feint)]
[InlineData( B, Heracross, 0, Megahorn, Reversal, Bulldoze, Fling)]
[InlineData( X, Growlithe, 0, Bite, Roar, FlareBlitz, MorningSun)]
[InlineData(OR, Growlithe, 0, MorningSun, IronTail, Crunch, HeatWave)]
[InlineData(OR, Dratini, 0, Wrap, Leer, DragonDance, ExtremeSpeed)]
[InlineData(OR, Rotom, 0, Astonish, ThunderWave, ThunderShock, ConfuseRay)]
[InlineData(BD, Gible, 0, IronHead, BodySlam, SandTomb, Outrage)]
[InlineData(BD, Gible, 0, IronHead, BodySlam, Outrage, SandTomb)]
[InlineData(BD, Gible, 0, BodySlam, Outrage, SandTomb, DragonBreath)]
public void VerifyBreed(GameVersion game, Species species, byte form, params Move[] movelist)
{
var gen = game.GetGeneration();
Span<ushort> moves = stackalloc ushort[MovesetCount];
GetMoves(movelist, moves);
var origins = new byte[moves.Length];
var valid = MoveBreed.Validate(gen, (ushort) species, form, game, moves, origins);
valid.Should().BeTrue();
var x = origins;
if (gen != 2)
x.SequenceEqual(x.OrderBy(z => z)).Should().BeTrue();
else
x.SequenceEqual(x.OrderBy(z => z != (byte)EggSource2.Base)).Should().BeTrue();
}
[Theory]
[InlineData(C, Igglybuff, 0, Charm, DefenseCurl, Sing, Flamethrower)] // invalid push-out order
[InlineData(SH, Honedge, 0, FuryCutter, WideGuard, DestinyBond)] // insufficient move count
[InlineData(OR, Rotom, 0, Discharge, Charge, Trick, ConfuseRay)] // invalid push-out order
[InlineData(OR, Rotom, 0, ThunderWave, ThunderShock, ConfuseRay, Discharge)] // no inheriting levelup
public void CheckBad(GameVersion game, Species species, byte form, params Move[] movelist)
{
var gen = game.GetGeneration();
Span<ushort> moves = stackalloc ushort[MovesetCount];
GetMoves(movelist, moves);
Span<byte> result = stackalloc byte[moves.Length];
var test = MoveBreed.Validate(gen, (ushort)species, form, game, moves, result);
test.Should().BeFalse();
}
[Theory]
[InlineData(GD, Bulbasaur, 0, Growl, Tackle)] // swap order, two base moves
[InlineData(UM, Charmander, 0, Ember, BellyDrum, Scratch, Growl)] // swap order, inherit + egg moves
[InlineData(BD, Gible, 0, BodySlam, SandTomb, Outrage, DragonBreath)]
public void CheckFix(GameVersion game, Species species, byte form, params Move[] movelist)
{
var gen = game.GetGeneration();
Span<ushort> moves = stackalloc ushort[MovesetCount];
GetMoves(movelist, moves);
Span<byte> result = stackalloc byte[moves.Length];
var valid = MoveBreed.Validate(gen, (ushort)species, form, game, moves, result);
valid.Should().BeFalse();
Span<ushort> expected = stackalloc ushort[moves.Length];
var useNew = MoveBreed.GetExpectedMoves(gen, (ushort)species, form, game, moves, result, expected);
useNew.Should().BeTrue();
// fixed order should be different now.
expected.SequenceEqual(moves).Should().BeFalse();
// nonzero move count should be same
expected.Count((ushort)0).Should().Be(moves.Count((ushort)0));
}
}