public PokemonTestParams( PKMN.Ball validBall, PKMN.Ball[] invalidBalls, PKMN.Item validItem, PKMN.Item[] invalidItems, string expectedOriginalLocation, string[] validLocations, string[] invalidLocations, PKMN.Move[] validMoves, PKMN.Move[] invalidMoves, PKMN.Game[] validOriginalGames, PKMN.Game[] invalidOriginalGames ) { ValidBall = validBall; InvalidBalls = invalidBalls; ValidItem = validItem; InvalidItems = invalidItems; ExpectedOriginalLocation = expectedOriginalLocation; ValidLocations = validLocations; InvalidLocations = invalidLocations; ValidMoves = validMoves; InvalidMoves = invalidMoves; ValidOriginalGames = validOriginalGames; InvalidOriginalGames = invalidOriginalGames; }
public static void TestItemListIndexOutOfRangeException( PKMN.ItemList itemList, PKMN.Item item ) { int oldNumItems = itemList.NumItems; Assert.Throws <IndexOutOfRangeException>( delegate { itemList.Add(item, 0); } ); Assert.Throws <IndexOutOfRangeException>( delegate { itemList.Remove(item, 100); } ); Assert.Throws <IndexOutOfRangeException>( delegate { itemList.Remove(item, 0); } ); Assert.Throws <IndexOutOfRangeException>( delegate { itemList.Add(item, 100); } ); // This shouldn't have added any items. Assert.AreEqual(oldNumItems, itemList.NumItems); }
public void ItemListTest() { // Make sure trying to create an invalid list results in an exception Assert.Throws <ArgumentOutOfRangeException>( delegate { PKMN.Database.Lists.ItemList(PKMN.Game.NONE); } ); Assert.Throws <ArgumentOutOfRangeException>( delegate { PKMN.Database.Lists.ItemNameList(PKMN.Game.NONE); } ); PKMN.ItemEnumList itemList = PKMN.Database.Lists.ItemList(PKMN.Game.HEARTGOLD); Assert.AreEqual(itemList.Count, 513); Assert.AreEqual(itemList[0], PKMN.Item.MASTER_BALL); Assert.AreEqual(itemList[512], PKMN.Item.PHOTO_ALBUM); PKMN.StringList itemNameList = PKMN.Database.Lists.ItemNameList(PKMN.Game.HEARTGOLD); Assert.AreEqual(itemNameList.Count, 513); Assert.AreEqual(itemNameList[0], "Master Ball"); Assert.AreEqual(itemNameList[512], "Photo Album"); // Make sure lists match. Note that for items, we need to check from // name to enum, as there are multiple names for some items but always // a single enum. Assert.AreEqual(itemList.Count, itemNameList.Count); for (int itemIndex = 0; itemIndex < itemList.Count; ++itemIndex) { PKMN.Item item = PKMN.PKMN.StringToItem(itemNameList[itemIndex]); Assert.AreEqual(item, itemList[itemIndex]); } }
public static void TMHMPocketTest( PKMN.ItemList tmhmPocket, PKMN.Game game ) { // Check unchanging and initial values. Assert.AreEqual(tmhmPocket.Name, "TM/HM"); Assert.AreEqual(tmhmPocket.Game, game); Assert.AreEqual(tmhmPocket.Length, 57); Assert.AreEqual(tmhmPocket.NumItems, 0); // Make sure item slots start as correctly empty. Assert.AreEqual(tmhmPocket.Length, 57); for (int tmIndex = 1; tmIndex <= 50; ++tmIndex) { PKMN.Item expectedItem = (PKMN.Item.TM01 + (tmIndex - 1)); Assert.AreEqual(tmhmPocket[tmIndex - 1].Item, expectedItem); Assert.AreEqual(tmhmPocket[tmIndex - 1].Amount, 0); } for (int hmIndex = 1; hmIndex <= 7; ++hmIndex) { PKMN.Item expectedItem = (PKMN.Item.HM01 + (hmIndex - 1)); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Item, expectedItem); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Amount, 0); } // Confirm exceptions are thrown when expected. ItemsTestsCommon.TestItemListIndexOutOfRangeException( tmhmPocket, PKMN.Item.TM10 ); // Confirm items from other pockets can't be added. ItemsTestsCommon.TestItemListInvalidItems( tmhmPocket, new PKMN.Item[] { PKMN.Item.BICYCLE, PKMN.Item.MASTER_BALL, PKMN.Item.BICYCLE } ); // Confirm items from later generations can't be added. ItemsTestsCommon.TestItemListInvalidItems( tmhmPocket, new PKMN.Item[] { PKMN.Item.TM51 } ); // Start adding and removing stuff, and make sure the numbers are accurate. for (int tmIndex = 1; tmIndex <= 50; ++tmIndex) { PKMN.Item item = (PKMN.Item.TM01 + (tmIndex - 1)); tmhmPocket.Add(item, 50); Assert.AreEqual(tmhmPocket.NumItems, tmIndex); Assert.AreEqual(tmhmPocket[tmIndex - 1].Item, item); Assert.AreEqual(tmhmPocket[tmIndex - 1].Amount, 50); } for (int tmIndex = 50; tmIndex >= 1; --tmIndex) { PKMN.Item item = (PKMN.Item.TM01 + (tmIndex - 1)); tmhmPocket.Remove(item, 50); Assert.AreEqual(tmhmPocket.NumItems, tmIndex - 1); Assert.AreEqual(tmhmPocket[tmIndex - 1].Item, item); Assert.AreEqual(tmhmPocket[tmIndex - 1].Amount, 0); } for (int hmIndex = 1; hmIndex <= 7; ++hmIndex) { PKMN.Item item = (PKMN.Item.HM01 + (hmIndex - 1)); tmhmPocket.Add(item, 1); Assert.AreEqual(tmhmPocket.NumItems, hmIndex); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Item, item); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Amount, 1); } for (int hmIndex = 7; hmIndex >= 1; --hmIndex) { PKMN.Item item = (PKMN.Item.HM01 + (hmIndex - 1)); tmhmPocket.Remove(item, 1); Assert.AreEqual(tmhmPocket.NumItems, hmIndex - 1); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Item, item); Assert.AreEqual(tmhmPocket[50 + hmIndex - 1].Amount, 0); } Assert.AreEqual(tmhmPocket.ValidItems.Count, tmhmPocket.ValidItemNames.Count); Assert.AreEqual(tmhmPocket.ValidItems.Count, 57); }
public static void ConversionsTest( PKMN.Species species, string form, PKMN.Game originGame, PKMN.Game destGame ) { PKMN.Pokemon firstPokemon = new PKMN.Pokemon(species, originGame, form, 50); int originGeneration = Util.GameToGeneration(originGame); int destGeneration = Util.GameToGeneration(destGame); int minGeneration = System.Math.Min(originGeneration, destGeneration); PKMN.Game gameForLists = (minGeneration == originGeneration) ? originGame : destGame; PKMN.ItemEnumList items = PKMN.Database.Lists.ItemList(gameForLists); PKMN.MoveEnumList moves = PKMN.Database.Lists.MoveList(gameForLists); for (int i = 0; i < 4; ++i) { PKMN.Move move = PKMN.Move.NONE; do { move = moves[rng.Next(0, moves.Count - 1)]; }while(move >= PKMN.Move.SHADOW_RUSH); firstPokemon.Moves[i].Move = move; } if (originGeneration >= 3) { firstPokemon.OriginalTrainerSecretID = (ushort)rng.Next(0, 0xFFFF); if (firstPokemon.DatabaseEntry.Abilities.Second != PKMN.Ability.NONE) { firstPokemon.Ability = Util.RandomBool() ? firstPokemon.DatabaseEntry.Abilities.First : firstPokemon.DatabaseEntry.Abilities.Second; } } firstPokemon.OriginalTrainerPublicID = (ushort)rng.Next(0, 0xFFFF); if (minGeneration >= 2) { PKMN.Item heldItem = PKMN.Item.NONE; do { heldItem = items[rng.Next(0, items.Count - 1)]; } while(!(new PKMN.Database.ItemEntry(heldItem, originGame).IsHoldable) || ((heldItem >= PKMN.Item.JOY_SCENT) && (heldItem <= PKMN.Item.VIVID_SCENT))); firstPokemon.HeldItem = heldItem; } if (originGeneration >= 2) { firstPokemon.Gender = Util.RandomBool() ? PKMN.Gender.MALE : PKMN.Gender.FEMALE; firstPokemon.IsShiny = Util.RandomBool(); firstPokemon.CurrentTrainerFriendship = rng.Next(0, 255); if ((originGame == PKMN.Game.GOLD) || (originGame == PKMN.Game.CRYSTAL)) { firstPokemon.OriginalTrainerGender = Util.RandomBool() ? PKMN.Gender.MALE : PKMN.Gender.FEMALE; } // The max level met value in Generation II is 63. firstPokemon.LevelMet = rng.Next(2, (originGeneration == 2) ? 63 : 100); } if (originGeneration >= 3) { // Randomize ribbons, markings, and contest stats. foreach (PKMN.Marking marking in firstPokemon.Markings.Keys) { firstPokemon.Markings[marking] = Util.RandomBool(); } foreach (string ribbon in firstPokemon.Ribbons.Keys) { firstPokemon.Ribbons[ribbon] = Util.RandomBool(); } foreach (PKMN.ContestStat contestStat in firstPokemon.ContestStats.Keys) { firstPokemon.ContestStats[contestStat] = rng.Next(0, 255); } } firstPokemon.Nickname = Util.RandomString(10); firstPokemon.OriginalTrainerName = Util.RandomString(7); // The max level met value in Generation II is 63, which restricts this as well. firstPokemon.Level = rng.Next(2, (destGeneration == 2) ? 63 : 100); // Convert to the second game and compare. PKMN.Pokemon secondPokemon = firstPokemon.ToGame(destGame); Assert.AreEqual(firstPokemon.Species, secondPokemon.Species); Assert.AreEqual(destGame, secondPokemon.Game); Assert.AreEqual(firstPokemon.Form, secondPokemon.Form); Assert.AreEqual(firstPokemon.Nickname, secondPokemon.Nickname); Assert.AreEqual(firstPokemon.OriginalTrainerName, secondPokemon.OriginalTrainerName); Assert.AreEqual(firstPokemon.OriginalTrainerID, secondPokemon.OriginalTrainerID); Assert.AreEqual(firstPokemon.OriginalTrainerPublicID, secondPokemon.OriginalTrainerPublicID); Assert.AreEqual(firstPokemon.Experience, secondPokemon.Experience); Assert.AreEqual(firstPokemon.Level, secondPokemon.Level); for (int i = 0; i < 4; ++i) { Assert.AreEqual(firstPokemon.Moves[i].Move, secondPokemon.Moves[i].Move); Assert.AreEqual(firstPokemon.Moves[i].PP, secondPokemon.Moves[i].PP); } if (minGeneration >= 3) { Assert.AreEqual(firstPokemon.OriginalTrainerSecretID, secondPokemon.OriginalTrainerSecretID); Assert.AreEqual(firstPokemon.Ability, secondPokemon.Ability); Assert.AreEqual(firstPokemon.Ball, secondPokemon.Ball); Assert.AreEqual(firstPokemon.OriginalGame, secondPokemon.OriginalGame); Assert.AreEqual(firstPokemon.Personality, secondPokemon.Personality); if (originGeneration == destGeneration) { foreach (PKMN.Marking marking in firstPokemon.Markings.Keys) { Assert.AreEqual(firstPokemon.Markings[marking], secondPokemon.Markings[marking]); } foreach (string ribbon in firstPokemon.Ribbons.Keys) { Assert.AreEqual(firstPokemon.Ribbons[ribbon], secondPokemon.Ribbons[ribbon]); } foreach (PKMN.ContestStat contestStat in firstPokemon.ContestStats.Keys) { Assert.AreEqual(firstPokemon.ContestStats[contestStat], secondPokemon.ContestStats[contestStat]); } } } if (minGeneration >= 2) { Assert.AreEqual(firstPokemon.OriginalTrainerGender, secondPokemon.OriginalTrainerGender); Assert.AreEqual(firstPokemon.Gender, secondPokemon.Gender); Assert.AreEqual(firstPokemon.IsShiny, secondPokemon.IsShiny); Assert.AreEqual(firstPokemon.HeldItem, secondPokemon.HeldItem); Assert.AreEqual(firstPokemon.CurrentTrainerFriendship, secondPokemon.CurrentTrainerFriendship); Assert.AreEqual(firstPokemon.Level, secondPokemon.LevelMet); } }
public static void ItemBagTest( PKMN.ItemBag itemBag, PKMN.Game game ) { bool colosseum = (game == PKMN.Game.COLOSSEUM); PKMN.Item keyItem = colosseum ? PKMN.Item.EIN_FILE_S : PKMN.Item.GONZAPS_KEY; // Check unchanging and initial values. Assert.AreEqual(itemBag.Game, game); Assert.AreEqual(itemBag.Count, (colosseum ? 6 : 7)); ItemPocketTest(itemBag["Items"], game); KeyItemPocketTest(itemBag["Key Items"], game); BallPocketTest(itemBag["Poké Balls"], game); TMPocketTest(itemBag["TMs"], game); BerryPocketTest(itemBag["Berries"], game); ColognePocketTest(itemBag["Colognes"], game); if (!colosseum) { BattleCDPocketTest(itemBag["Battle CDs"], game); } // Make sure adding items through the bag adds to the proper pockets. Assert.AreEqual(itemBag["Items"].NumItems, 0); Assert.AreEqual(itemBag["Key Items"].NumItems, 0); Assert.AreEqual(itemBag["Poké Balls"].NumItems, 0); Assert.AreEqual(itemBag["TMs"].NumItems, 0); Assert.AreEqual(itemBag["Berries"].NumItems, 0); Assert.AreEqual(itemBag["Colognes"].NumItems, 0); if (!colosseum) { Assert.AreEqual(itemBag["Battle CDs"].NumItems, 0); } foreach (PKMN.Item item in (colosseum ? ColosseumAllPocketItems : XDAllPocketItems)) { itemBag.Add(item, 5); } Assert.AreEqual(itemBag["Items"][0].Item, PKMN.Item.POTION); Assert.AreEqual(itemBag["Items"][0].Amount, 5); Assert.AreEqual(itemBag["Items"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Items"][1].Amount, 0); Assert.AreEqual(itemBag["Key Items"][0].Item, keyItem); Assert.AreEqual(itemBag["Key Items"][0].Amount, 5); Assert.AreEqual(itemBag["Key Items"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Key Items"][1].Amount, 0); Assert.AreEqual(itemBag["Poké Balls"][0].Item, PKMN.Item.GREAT_BALL); Assert.AreEqual(itemBag["Poké Balls"][0].Amount, 5); Assert.AreEqual(itemBag["Poké Balls"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Poké Balls"][1].Amount, 0); Assert.AreEqual(itemBag["TMs"][0].Item, PKMN.Item.TM01); Assert.AreEqual(itemBag["TMs"][0].Amount, 5); Assert.AreEqual(itemBag["TMs"][1].Item, PKMN.Item.TM02); Assert.AreEqual(itemBag["TMs"][1].Amount, 5); Assert.AreEqual(itemBag["TMs"][2].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["TMs"][2].Amount, 0); Assert.AreEqual(itemBag["Berries"][0].Item, PKMN.Item.ASPEAR_BERRY); Assert.AreEqual(itemBag["Berries"][0].Amount, 5); Assert.AreEqual(itemBag["Berries"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Berries"][1].Amount, 0); Assert.AreEqual(itemBag["Colognes"][0].Item, PKMN.Item.JOY_SCENT); Assert.AreEqual(itemBag["Colognes"][0].Amount, 5); if (colosseum) { Assert.AreEqual(itemBag["Colognes"][1].Item, PKMN.Item.EXCITE_SCENT); Assert.AreEqual(itemBag["Colognes"][1].Amount, 5); Assert.AreEqual(itemBag["Colognes"][2].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][2].Amount, 0); } else { Assert.AreEqual(itemBag["Colognes"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][1].Amount, 0); Assert.AreEqual(itemBag["Battle CDs"][0].Item, PKMN.Item.BATTLE_CD_01); Assert.AreEqual(itemBag["Battle CDs"][0].Amount, 5); } // Make sure removing items through the bag removes from the proper pockets. foreach (PKMN.Item item in (colosseum ? ColosseumAllPocketItems : XDAllPocketItems)) { itemBag.Remove(item, 5); } Assert.AreEqual(itemBag["Items"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Items"][0].Amount, 0); Assert.AreEqual(itemBag["Items"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Items"][1].Amount, 0); Assert.AreEqual(itemBag["Key Items"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Key Items"][0].Amount, 0); Assert.AreEqual(itemBag["Key Items"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Key Items"][1].Amount, 0); Assert.AreEqual(itemBag["Poké Balls"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Poké Balls"][0].Amount, 0); Assert.AreEqual(itemBag["Poké Balls"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Poké Balls"][1].Amount, 0); Assert.AreEqual(itemBag["TMs"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["TMs"][0].Amount, 0); Assert.AreEqual(itemBag["TMs"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["TMs"][1].Amount, 0); Assert.AreEqual(itemBag["TMs"][2].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["TMs"][2].Amount, 0); Assert.AreEqual(itemBag["Berries"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Berries"][0].Amount, 0); Assert.AreEqual(itemBag["Berries"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Berries"][1].Amount, 0); Assert.AreEqual(itemBag["Colognes"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][0].Amount, 0); if (colosseum) { Assert.AreEqual(itemBag["Colognes"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][1].Amount, 0); Assert.AreEqual(itemBag["Colognes"][2].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][2].Amount, 0); } else { Assert.AreEqual(itemBag["Colognes"][1].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Colognes"][1].Amount, 0); Assert.AreEqual(itemBag["Battle CDs"][0].Item, PKMN.Item.NONE); Assert.AreEqual(itemBag["Battle CDs"][0].Amount, 0); } ItemsTestsCommon.TestItemBagInvalidItems( itemBag, colosseum ? ColosseumWrongGameAllPocketItems : XDWrongGameAllPocketItems ); }
public static void KeyItemPocketTest( PKMN.ItemList keyItemPocket, PKMN.Game game ) { bool colosseum = (game == PKMN.Game.COLOSSEUM); PKMN.Item keyItem = colosseum ? PKMN.Item.EIN_FILE_S : PKMN.Item.GONZAPS_KEY; int expectedLength = 43; // Check unchanging and initial values. Assert.AreEqual(keyItemPocket.Name, "Key Items"); Assert.AreEqual(keyItemPocket.Game, game); Assert.AreEqual(keyItemPocket.Length, expectedLength); Assert.AreEqual(keyItemPocket.NumItems, 0); // Make sure item slots start as correctly empty. ItemsTestsCommon.TestItemListEmptySlots(keyItemPocket); // Confirm exceptions are thrown when expected. ItemsTestsCommon.TestItemListIndexOutOfRangeException( keyItemPocket, keyItem ); // Confirm items from other pockets can't be added. if (colosseum) { ItemsTestsCommon.TestItemListInvalidItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.POTION, PKMN.Item.GREAT_BALL, PKMN.Item.TM01, PKMN.Item.ORAN_BERRY, PKMN.Item.JOY_SCENT } ); } else { ItemsTestsCommon.TestItemListInvalidItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.POTION, PKMN.Item.GREAT_BALL, PKMN.Item.TM01, PKMN.Item.ORAN_BERRY, PKMN.Item.JOY_SCENT, PKMN.Item.BATTLE_CD_01 } ); } // Confirm items from other generations can't be added. ItemsTestsCommon.TestItemListInvalidItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.GS_BALL, PKMN.Item.POFFIN_CASE, PKMN.Item.DNA_SPLICERS, PKMN.Item.AQUA_SUIT } ); // Confirm items from incompatible Generation III games can't be added. ItemsTestsCommon.TestItemListInvalidItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.HELIX_FOSSIL, PKMN.Item.TEA, PKMN.Item.RUBY } ); ItemsTestsCommon.TestItemListInvalidItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.MAGMA_EMBLEM, PKMN.Item.OLD_SEA_MAP } ); // Start adding and removing stuff, and make sure the numbers are accurate. if (colosseum) { ItemsTestsCommon.TestItemListSettingItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.JAIL_KEY, PKMN.Item.ELEVATOR_KEY, PKMN.Item.SMALL_TABLET, PKMN.Item.F_DISK, PKMN.Item.R_DISK, PKMN.Item.L_DISK, PKMN.Item.D_DISK, PKMN.Item.U_DISK } ); ItemsTestsCommon.TestItemListAddingAndRemovingItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.JAIL_KEY, PKMN.Item.ELEVATOR_KEY, PKMN.Item.SMALL_TABLET, PKMN.Item.F_DISK, PKMN.Item.R_DISK, PKMN.Item.L_DISK, PKMN.Item.D_DISK, PKMN.Item.U_DISK } ); } else { ItemsTestsCommon.TestItemListSettingItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.KRANE_MEMO_1, PKMN.Item.KRANE_MEMO_2, PKMN.Item.KRANE_MEMO_3, PKMN.Item.KRANE_MEMO_4, PKMN.Item.KRANE_MEMO_5, PKMN.Item.VOICE_CASE_1, PKMN.Item.VOICE_CASE_2, PKMN.Item.VOICE_CASE_3 } ); ItemsTestsCommon.TestItemListAddingAndRemovingItems( keyItemPocket, new PKMN.Item[] { PKMN.Item.KRANE_MEMO_1, PKMN.Item.KRANE_MEMO_2, PKMN.Item.KRANE_MEMO_3, PKMN.Item.KRANE_MEMO_4, PKMN.Item.KRANE_MEMO_5, PKMN.Item.VOICE_CASE_1, PKMN.Item.VOICE_CASE_2, PKMN.Item.VOICE_CASE_3 } ); } Assert.AreEqual(keyItemPocket.ValidItems.Count, keyItemPocket.ValidItemNames.Count); Assert.Greater(keyItemPocket.ValidItems.Count, 0); }