コード例 #1
0
        public static void ItemPCTest(
            PKMN.ItemList itemPC,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemPC.Name, "PC");
            Assert.AreEqual(itemPC.Game, game);
            Assert.AreEqual(itemPC.Length, 50);
            Assert.AreEqual(itemPC.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPC);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPC,
                PKMN.Item.POTION
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPC,
                WrongGenerationAllPocketItems
                );

            // Crystal-specific items.
            if (game == PKMN.Game.CRYSTAL)
            {
                foreach (PKMN.Item crystalItem in CrystalItems)
                {
                    itemPC.Add(crystalItem, 1);
                    itemPC.Remove(crystalItem, 1);
                }

                Assert.AreEqual(itemPC.NumItems, 0);
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    itemPC,
                    CrystalItems
                    );
            }

            // Start adding and removing stuff, and make sure the numbers are accurate.
            ItemsTestsCommon.TestItemListSettingItems(
                itemPC,
                AllPocketItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPC,
                AllPocketItems
                );

            PKMN.ItemEnumList fullItemList = PKMN.Database.Lists.ItemList(game);

            Assert.AreEqual(itemPC.ValidItems.Count, itemPC.ValidItemNames.Count);
            Assert.AreEqual(itemPC.ValidItems.Count, fullItemList.Count);
        }
コード例 #2
0
ファイル: Gen1ItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemListCommon(
            PKMN.ItemList itemList,
            PKMN.Game game
            )
        {
            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemList);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemList,
                PKMN.Item.POTION
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemList,
                WrongGenerationItems
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            ItemsTestsCommon.TestItemListSettingItems(
                itemList,
                Items
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemList,
                Items
                );

            PKMN.ItemEnumList fullItemList = PKMN.Database.Lists.ItemList(game);

            Assert.AreEqual(itemList.ValidItems.Count, itemList.ValidItemNames.Count);
            Assert.AreEqual(itemList.ValidItems.Count, fullItemList.Count);
        }
コード例 #3
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void BattleCDPocketTest(
            PKMN.ItemList battleCDPocket,
            PKMN.Game game
            )
        {
            int expectedLength = 60;

            // Check unchanging and initial values.
            Assert.AreEqual(battleCDPocket.Name, "Battle CDs");
            Assert.AreEqual(battleCDPocket.Game, game);
            Assert.AreEqual(battleCDPocket.Length, expectedLength);
            Assert.AreEqual(battleCDPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(battleCDPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                battleCDPocket,
                PKMN.Item.BATTLE_CD_01
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                battleCDPocket,
                new PKMN.Item[]
            {
                PKMN.Item.GONZAPS_KEY,
                PKMN.Item.POTION,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.TM01,
                PKMN.Item.JOY_SCENT,
                PKMN.Item.ORAN_BERRY,
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.BATTLE_CD_01,
                PKMN.Item.BATTLE_CD_02,
                PKMN.Item.BATTLE_CD_03,
                PKMN.Item.BATTLE_CD_04,
                PKMN.Item.BATTLE_CD_05,
                PKMN.Item.BATTLE_CD_06,
                PKMN.Item.BATTLE_CD_07,
                PKMN.Item.BATTLE_CD_08
            };
            ItemsTestsCommon.TestItemListSettingItems(
                battleCDPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                battleCDPocket,
                validItems
                );

            Assert.AreEqual(battleCDPocket.ValidItems.Count, battleCDPocket.ValidItemNames.Count);
            Assert.AreEqual(battleCDPocket.ValidItems.Count, 60);
        }
コード例 #4
0
ファイル: ItemsTestsCommon.cs プロジェクト: ncorgan/libpkmn
        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);
        }
コード例 #5
0
        public static void ItemPCTest(
            PKMN.ItemList itemPC,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemPC.Name, "PC");
            Assert.AreEqual(itemPC.Game, game);
            Assert.AreEqual(itemPC.Length, 50);
            Assert.AreEqual(itemPC.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPC);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPC,
                PKMN.Item.POTION
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPC,
                WrongGameAllPocketItems
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            ItemsTestsCommon.TestItemListSettingItems(
                itemPC,
                AllPocketItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPC,
                AllPocketItems
                );

            Assert.AreEqual(itemPC.ValidItems.Count, itemPC.ValidItemNames.Count);

            PKMN.ItemEnumList fullItemList     = PKMN.Database.Lists.ItemList(game);
            PKMN.StringList   fullItemNameList = PKMN.Database.Lists.ItemNameList(game);
            Assert.AreEqual(fullItemList.Count, fullItemNameList.Count);

            if ((game == PKMN.Game.FIRERED) || (game == PKMN.Game.LEAFGREEN))
            {
                Assert.AreEqual(itemPC.ValidItems.Count, fullItemList.Count - 2);

                Assert.IsFalse(itemPC.ValidItems.Contains(PKMN.Item.BERRY_POUCH));
                Assert.IsFalse(itemPC.ValidItems.Contains(PKMN.Item.TM_CASE));

                Assert.IsFalse(itemPC.ValidItemNames.Contains("Berry Pouch"));
                Assert.IsFalse(itemPC.ValidItemNames.Contains("TM Case"));
            }
            else
            {
                Assert.AreEqual(itemPC.ValidItems.Count, fullItemList.Count);
            }
        }
コード例 #6
0
ファイル: ItemsTestsCommon.cs プロジェクト: ncorgan/libpkmn
 public static void TestItemListEmptySlots(
     PKMN.ItemList itemList
     )
 {
     Assert.AreEqual(0, itemList.NumItems);
     for (int itemIndex = 0; itemIndex < itemList.Length; ++itemIndex)
     {
         Assert.AreEqual(PKMN.Item.NONE, itemList[itemIndex].Item);
         Assert.AreEqual(0, itemList[itemIndex].Amount);
     }
 }
コード例 #7
0
ファイル: Gen1ItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemPCTest(
            PKMN.ItemList itemPC,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemPC.Name, "PC");
            Assert.AreEqual(itemPC.Game, game);
            Assert.AreEqual(itemPC.Length, 50);
            Assert.AreEqual(itemPC.NumItems, 0);

            ItemListCommon(itemPC, game);
        }
コード例 #8
0
ファイル: Gen1ItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemListTest(
            PKMN.ItemList itemList,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemList.Name, "Items");
            Assert.AreEqual(itemList.Game, game);
            Assert.AreEqual(itemList.Length, 20);
            Assert.AreEqual(itemList.NumItems, 0);

            ItemListCommon(itemList, game);
        }
コード例 #9
0
ファイル: Gen1ItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemBagTest(
            PKMN.ItemBag itemBag,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemBag.Game, game);
            Assert.AreEqual(itemBag.Count, 1);

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemBagInvalidItems(
                itemBag,
                WrongGenerationItems
                );

            ItemListTest(itemBag["Items"], game);

            // Make sure adding items through the bag adds to the pocket.
            PKMN.ItemList itemPocket = itemBag["Items"];
            Assert.AreEqual(itemPocket.NumItems, 0);

            for (int i = 0; i < 8; ++i)
            {
                itemBag.Add(
                    Items[i],
                    i + 1
                    );
            }
            for (int i = 0; i < 8; ++i)
            {
                Assert.AreEqual(itemPocket[i].Item, Items[i]);
                Assert.AreEqual(itemPocket[i].Amount, i + 1);
            }
            Assert.AreEqual(itemPocket[8].Item, PKMN.Item.NONE);
            Assert.AreEqual(itemPocket[8].Amount, 0);

            for (int i = 0; i < 8; ++i)
            {
                itemBag.Remove(
                    Items[i],
                    i + 1
                    );
            }
            for (int i = 0; i < 9; ++i)
            {
                Assert.AreEqual(itemPocket[i].Item, PKMN.Item.NONE);
                Assert.AreEqual(itemPocket[i].Amount, 0);
            }
        }
コード例 #10
0
ファイル: GameSaveTest.cs プロジェクト: ncorgan/libpkmn
        private static void CompareItemLists(
            PKMN.ItemList itemList1,
            PKMN.ItemList itemList2
            )
        {
            Assert.AreEqual(itemList1.Game, itemList2.Game);
            Assert.AreEqual(itemList1.Name, itemList2.Name);
            Assert.AreEqual(itemList1.Length, itemList2.Length);
            Assert.AreEqual(itemList1.NumItems, itemList2.NumItems);

            for (int i = 0; i < itemList1.Length; ++i)
            {
                Assert.AreEqual(itemList1[i].Item, itemList2[i].Item);
                Assert.AreEqual(itemList1[i].Amount, itemList2[i].Amount);
            }
        }
コード例 #11
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemPCTest(
            PKMN.ItemList itemPC,
            PKMN.Game game
            )
        {
            bool colosseum = (game == PKMN.Game.COLOSSEUM);

            // Check unchanging and initial values.
            Assert.AreEqual(itemPC.Name, "PC");
            Assert.AreEqual(itemPC.Game, game);
            Assert.AreEqual(itemPC.Length, 235);
            Assert.AreEqual(itemPC.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPC);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPC,
                PKMN.Item.POTION
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPC,
                colosseum ? ColosseumWrongGameAllPocketItems : XDWrongGameAllPocketItems
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            ItemsTestsCommon.TestItemListSettingItems(
                itemPC,
                colosseum ? ColosseumAllPocketItems : XDAllPocketItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPC,
                colosseum ? ColosseumAllPocketItems : XDAllPocketItems
                );

            PKMN.ItemEnumList fullItemList     = PKMN.Database.Lists.ItemList(game);
            PKMN.StringList   fullItemNameList = PKMN.Database.Lists.ItemNameList(game);

            Assert.AreEqual(itemPC.ValidItems.Count, itemPC.ValidItemNames.Count);
            Assert.AreEqual(itemPC.ValidItems.Count, fullItemList.Count);
            Assert.AreEqual(itemPC.ValidItemNames.Count, fullItemNameList.Count);
        }
コード例 #12
0
ファイル: ItemsTestsCommon.cs プロジェクト: ncorgan/libpkmn
        public static void TestItemListInvalidItems(
            PKMN.ItemList itemList,
            PKMN.Item[] items
            )
        {
            int oldNumItems = itemList.NumItems;

            foreach (PKMN.Item itemName in items)
            {
                Assert.Throws <ArgumentOutOfRangeException>(
                    delegate
                {
                    itemList.Add(itemName, 1);
                }
                    );
            }

            // This shouldn't have added any items.
            Assert.AreEqual(oldNumItems, itemList.NumItems);
        }
コード例 #13
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        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);
        }
コード例 #14
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void BallPocketTest(
            PKMN.ItemList ballPocket,
            PKMN.Game game
            )
        {
            bool colosseum      = (game == PKMN.Game.COLOSSEUM);
            int  expectedLength = 16;

            // Check unchanging and initial values.
            Assert.AreEqual(ballPocket.Name, "Poké Balls");
            Assert.AreEqual(ballPocket.Game, game);
            Assert.AreEqual(ballPocket.Length, expectedLength);
            Assert.AreEqual(ballPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(ballPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                ballPocket,
                PKMN.Item.MASTER_BALL
                );

            // Confirm items from other pockets can't be added.
            if (colosseum)
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    ballPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.EIN_FILE_S,
                    PKMN.Item.POTION,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.JOY_SCENT
                }
                    );
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    ballPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.GONZAPS_KEY,
                    PKMN.Item.POTION,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.JOY_SCENT,
                    PKMN.Item.BATTLE_CD_01
                }
                    );
            }

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                ballPocket,
                new PKMN.Item[]
            {
                PKMN.Item.MOON_BALL,
                PKMN.Item.HEAL_BALL,
                PKMN.Item.DREAM_BALL
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.MASTER_BALL,
                PKMN.Item.ULTRA_BALL,
                PKMN.Item.GREAT_BALL,
                PKMN.Item.POKE_BALL,
                PKMN.Item.SAFARI_BALL,
                PKMN.Item.NET_BALL,
                PKMN.Item.DIVE_BALL,
                PKMN.Item.NEST_BALL
            };
            ItemsTestsCommon.TestItemListSettingItems(
                ballPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                ballPocket,
                validItems
                );

            Assert.AreEqual(ballPocket.ValidItems.Count, ballPocket.ValidItemNames.Count);
            Assert.Greater(ballPocket.ValidItems.Count, 0);
        }
コード例 #15
0
        public static void BerryPocketTest(
            PKMN.ItemList berryPocket,
            PKMN.Game game
            )
        {
            int    expectedLength = 0;
            string expectedName   = "";

            if ((game == PKMN.Game.FIRERED) || (game == PKMN.Game.LEAFGREEN))
            {
                expectedLength = 43;
                expectedName   = "Berry Pouch";
            }
            else
            {
                expectedLength = 46;
                expectedName   = "Berries";
            }

            // Check unchanging and initial values.
            Assert.AreEqual(berryPocket.Name, expectedName);
            Assert.AreEqual(berryPocket.Game, game);
            Assert.AreEqual(berryPocket.Length, expectedLength);
            Assert.AreEqual(berryPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(berryPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                berryPocket,
                PKMN.Item.RAZZ_BERRY
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                berryPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.BICYCLE,
                PKMN.Item.GREAT_BALL,
                PKMN.Item.HM02
            }
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                berryPocket,
                new PKMN.Item[]
            {
                PKMN.Item.BERRY,
                PKMN.Item.OCCA_BERRY,
                PKMN.Item.ROSELI_BERRY
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.CHERI_BERRY,
                PKMN.Item.RAZZ_BERRY,
                PKMN.Item.LUM_BERRY,
                PKMN.Item.PINAP_BERRY,
                PKMN.Item.ASPEAR_BERRY,
                PKMN.Item.IAPAPA_BERRY,
                PKMN.Item.WIKI_BERRY,
                PKMN.Item.APICOT_BERRY
            };
            ItemsTestsCommon.TestItemListSettingItems(
                berryPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                berryPocket,
                validItems
                );

            Assert.AreEqual(berryPocket.ValidItems.Count, berryPocket.ValidItemNames.Count);
            Assert.Greater(berryPocket.ValidItems.Count, 0);
        }
コード例 #16
0
        public static void ItemPocketTest(
            PKMN.ItemList itemPocket,
            PKMN.Game game
            )
        {
            int expectedLength = 0;

            if ((game == PKMN.Game.RUBY) || (game == PKMN.Game.SAPPHIRE))
            {
                expectedLength = 20;
            }
            else if (game == PKMN.Game.EMERALD)
            {
                expectedLength = 30;
            }
            else
            {
                expectedLength = 42;
            }

            // Check unchanging and initial values.
            Assert.AreEqual(itemPocket.Name, "Items");
            Assert.AreEqual(itemPocket.Game, game);
            Assert.AreEqual(itemPocket.Length, expectedLength);
            Assert.AreEqual(itemPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPocket,
                PKMN.Item.POTION
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.BICYCLE,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.HM01,
                PKMN.Item.RAZZ_BERRY
            }
                );

            // Confirm items from other generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.PINK_BOW,
                PKMN.Item.BLACK_SLUDGE,
                PKMN.Item.BINDING_BAND,
                PKMN.Item.BEEDRILLITE
            }
                );

            // Make sure we can't add items from Gamecube games.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.TIME_FLUTE,
                PKMN.Item.POKE_SNACK
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.POTION,
                PKMN.Item.ORANGE_MAIL,
                PKMN.Item.LAVA_COOKIE,
                PKMN.Item.STARDUST,
                PKMN.Item.SHADOW_MAIL,
                PKMN.Item.PINK_SCARF,
                PKMN.Item.ANTIDOTE,
                PKMN.Item.GREEN_SHARD
            };
            ItemsTestsCommon.TestItemListSettingItems(
                itemPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPocket,
                validItems
                );

            Assert.AreEqual(itemPocket.ValidItems.Count, itemPocket.ValidItemNames.Count);
            Assert.Greater(itemPocket.ValidItems.Count, 0);
        }
コード例 #17
0
        public static void TMHMPocketTest(
            PKMN.ItemList tmhmPocket,
            PKMN.Game game
            )
        {
            int    expectedLength = 0;
            string expectedName   = "";

            if ((game == PKMN.Game.FIRERED) || (game == PKMN.Game.LEAFGREEN))
            {
                expectedLength = 58;
                expectedName   = "TM Case";
            }
            else
            {
                expectedLength = 64;
                expectedName   = "TMs & HMs";
            }

            // Check unchanging and initial values.
            Assert.AreEqual(tmhmPocket.Name, expectedName);
            Assert.AreEqual(tmhmPocket.Game, game);
            Assert.AreEqual(tmhmPocket.Length, expectedLength);
            Assert.AreEqual(tmhmPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(tmhmPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                tmhmPocket,
                PKMN.Item.TM01
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                tmhmPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.BICYCLE,
                PKMN.Item.GREAT_BALL,
                PKMN.Item.RAZZ_BERRY
            }
                );

            // 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.
            PKMN.Item[] validItems =
            {
                PKMN.Item.TM01,
                PKMN.Item.HM01,
                PKMN.Item.TM02,
                PKMN.Item.HM02,
                PKMN.Item.TM03,
                PKMN.Item.HM03,
                PKMN.Item.TM04,
                PKMN.Item.HM04
            };
            ItemsTestsCommon.TestItemListSettingItems(
                tmhmPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                tmhmPocket,
                validItems
                );

            Assert.AreEqual(tmhmPocket.ValidItems.Count, tmhmPocket.ValidItemNames.Count);
            Assert.Greater(tmhmPocket.ValidItems.Count, 0);
        }
コード例 #18
0
        public static void BallPocketTest(
            PKMN.ItemList ballPocket,
            PKMN.Game game
            )
        {
            int expectedLength = 0;

            if ((game == PKMN.Game.FIRERED) || (game == PKMN.Game.LEAFGREEN))
            {
                expectedLength = 13;
            }
            else
            {
                expectedLength = 16;
            }

            // Check unchanging and initial values.
            Assert.AreEqual(ballPocket.Name, "Poké Balls");
            Assert.AreEqual(ballPocket.Game, game);
            Assert.AreEqual(ballPocket.Length, expectedLength);
            Assert.AreEqual(ballPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(ballPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                ballPocket,
                PKMN.Item.MASTER_BALL
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                ballPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.BICYCLE,
                PKMN.Item.HM01,
                PKMN.Item.RAZZ_BERRY
            }
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                ballPocket,
                new PKMN.Item[]
            {
                PKMN.Item.MOON_BALL,
                PKMN.Item.HEAL_BALL,
                PKMN.Item.DREAM_BALL
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.MASTER_BALL,
                PKMN.Item.ULTRA_BALL,
                PKMN.Item.GREAT_BALL,
                PKMN.Item.POKE_BALL,
                PKMN.Item.SAFARI_BALL,
                PKMN.Item.NET_BALL,
                PKMN.Item.DIVE_BALL,
                PKMN.Item.NEST_BALL
            };
            ItemsTestsCommon.TestItemListSettingItems(
                ballPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                ballPocket,
                validItems
                );

            Assert.AreEqual(ballPocket.ValidItems.Count, ballPocket.ValidItemNames.Count);
            Assert.Greater(ballPocket.ValidItems.Count, 0);
        }
コード例 #19
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ItemPocketTest(
            PKMN.ItemList itemPocket,
            PKMN.Game game
            )
        {
            bool colosseum      = (game == PKMN.Game.COLOSSEUM);
            int  expectedLength = colosseum ? 20 : 30;

            // Check unchanging and initial values.
            Assert.AreEqual(itemPocket.Name, "Items");
            Assert.AreEqual(itemPocket.Game, game);
            Assert.AreEqual(itemPocket.Length, expectedLength);
            Assert.AreEqual(itemPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPocket,
                PKMN.Item.POTION
                );

            // Confirm items from other pockets can't be added.
            if (colosseum)
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    itemPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.EIN_FILE_S,
                    PKMN.Item.GREAT_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.JOY_SCENT
                }
                    );
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    itemPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.GONZAPS_KEY,
                    PKMN.Item.GREAT_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.BATTLE_CD_01
                }
                    );
            }

            // Confirm items from other generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.PINK_BOW,
                PKMN.Item.BLACK_SLUDGE,
                PKMN.Item.BINDING_BAND,
                PKMN.Item.BEEDRILLITE
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.POTION,
                PKMN.Item.ORANGE_MAIL,
                PKMN.Item.LAVA_COOKIE,
                PKMN.Item.STARDUST,
                PKMN.Item.SHADOW_MAIL,
                PKMN.Item.PINK_SCARF,
                PKMN.Item.ANTIDOTE,
                PKMN.Item.GREEN_SHARD
            };
            ItemsTestsCommon.TestItemListSettingItems(
                itemPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPocket,
                validItems
                );

            Assert.AreEqual(itemPocket.ValidItems.Count, itemPocket.ValidItemNames.Count);
            Assert.Greater(itemPocket.ValidItems.Count, 0);
        }
コード例 #20
0
        public static void ItemPocketTest(
            PKMN.ItemList itemPocket,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(itemPocket.Name, "Items");
            Assert.AreEqual(itemPocket.Game, game);
            Assert.AreEqual(itemPocket.Length, 20);
            Assert.AreEqual(itemPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(itemPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                itemPocket,
                PKMN.Item.POTION
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.BICYCLE,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.HM01
            }
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                itemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.BLACK_FLUTE,
                PKMN.Item.BLACK_SLUDGE,
                PKMN.Item.BINDING_BAND,
                PKMN.Item.BEEDRILLITE
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.POTION,
                PKMN.Item.HP_UP,
                PKMN.Item.WHITE_APRICORN,
                PKMN.Item.LUCKY_EGG,
                PKMN.Item.FLOWER_MAIL,
                PKMN.Item.BURN_HEAL,
                PKMN.Item.PSNCUREBERRY,
                PKMN.Item.STICK
            };
            ItemsTestsCommon.TestItemListSettingItems(
                itemPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                itemPocket,
                validItems
                );

            Assert.AreEqual(itemPocket.ValidItems.Count, itemPocket.ValidItemNames.Count);
            Assert.Greater(itemPocket.ValidItems.Count, 0);
        }
コード例 #21
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void TMPocketTest(
            PKMN.ItemList tmPocket,
            PKMN.Game game
            )
        {
            bool colosseum      = (game == PKMN.Game.COLOSSEUM);
            int  expectedLength = 64;

            // Check unchanging and initial values.
            Assert.AreEqual(tmPocket.Name, "TMs");
            Assert.AreEqual(tmPocket.Game, game);
            Assert.AreEqual(tmPocket.Length, expectedLength);
            Assert.AreEqual(tmPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(tmPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                tmPocket,
                PKMN.Item.TM01
                );

            // Confirm items from other pockets can't be added.
            if (colosseum)
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    tmPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.EIN_FILE_S,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.JOY_SCENT
                }
                    );
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    tmPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.GONZAPS_KEY,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.JOY_SCENT,
                    PKMN.Item.BATTLE_CD_01
                }
                    );
            }

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                tmPocket,
                new PKMN.Item[]
            {
                PKMN.Item.TM51,
                PKMN.Item.HM01
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.TM01,
                PKMN.Item.TM02,
                PKMN.Item.TM03,
                PKMN.Item.TM04,
                PKMN.Item.TM05,
                PKMN.Item.TM06,
                PKMN.Item.TM07,
                PKMN.Item.TM08
            };
            ItemsTestsCommon.TestItemListSettingItems(
                tmPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                tmPocket,
                validItems
                );

            Assert.AreEqual(tmPocket.ValidItems.Count, tmPocket.ValidItemNames.Count);
            Assert.AreEqual(tmPocket.ValidItems.Count, 50);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void BerryPocketTest(
            PKMN.ItemList berryPocket,
            PKMN.Game game
            )
        {
            bool colosseum      = (game == PKMN.Game.COLOSSEUM);
            int  expectedLength = 46;

            // Check unchanging and initial values.
            Assert.AreEqual(berryPocket.Name, "Berries");
            Assert.AreEqual(berryPocket.Game, game);
            Assert.AreEqual(berryPocket.Length, expectedLength);
            Assert.AreEqual(berryPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(berryPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                berryPocket,
                PKMN.Item.RAZZ_BERRY
                );

            // Confirm items from other pockets can't be added.
            if (colosseum)
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    berryPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.EIN_FILE_S,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.JOY_SCENT
                }
                    );
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    berryPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.GONZAPS_KEY,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.JOY_SCENT,
                    PKMN.Item.BATTLE_CD_01
                }
                    );
            }

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                berryPocket,
                new PKMN.Item[]
            {
                PKMN.Item.BERRY,
                PKMN.Item.OCCA_BERRY,
                PKMN.Item.ROSELI_BERRY
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.CHERI_BERRY,
                PKMN.Item.RAZZ_BERRY,
                PKMN.Item.LUM_BERRY,
                PKMN.Item.PINAP_BERRY,
                PKMN.Item.ASPEAR_BERRY,
                PKMN.Item.IAPAPA_BERRY,
                PKMN.Item.WIKI_BERRY,
                PKMN.Item.APICOT_BERRY
            };
            ItemsTestsCommon.TestItemListSettingItems(
                berryPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                berryPocket,
                validItems
                );

            Assert.AreEqual(berryPocket.ValidItems.Count, berryPocket.ValidItemNames.Count);
            Assert.Greater(berryPocket.ValidItems.Count, 0);
        }
コード例 #24
0
ファイル: ItemsTestsCommon.cs プロジェクト: ncorgan/libpkmn
        public static void TestItemListAddingAndRemovingItems(
            PKMN.ItemList itemList,
            PKMN.Item[] items
            )
        {
            Assert.AreEqual(0, itemList.NumItems);
            Assert.AreEqual(8, items.Length);

            itemList.Add(items[0], 30);
            itemList.Add(items[1], 99);
            itemList.Add(items[2], 1);

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[0], itemList[0].Item);
            Assert.AreEqual(30, itemList[0].Amount);
            Assert.AreEqual(items[1], itemList[1].Item);
            Assert.AreEqual(99, itemList[1].Amount);
            Assert.AreEqual(items[2], itemList[2].Item);
            Assert.AreEqual(1, itemList[2].Amount);

            itemList.Add(items[2], 15);

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[0], itemList[0].Item);
            Assert.AreEqual(30, itemList[0].Amount);
            Assert.AreEqual(items[1], itemList[1].Item);
            Assert.AreEqual(99, itemList[1].Amount);
            Assert.AreEqual(items[2], itemList[2].Item);
            Assert.AreEqual(16, itemList[2].Amount);

            itemList.Remove(items[1], 20);

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[0], itemList[0].Item);
            Assert.AreEqual(30, itemList[0].Amount);
            Assert.AreEqual(items[1], itemList[1].Item);
            Assert.AreEqual(79, itemList[1].Amount);
            Assert.AreEqual(items[2], itemList[2].Item);
            Assert.AreEqual(16, itemList[2].Amount);

            itemList.Move(0, 1);

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(79, itemList[0].Amount);
            Assert.AreEqual(items[0], itemList[1].Item);
            Assert.AreEqual(30, itemList[1].Amount);
            Assert.AreEqual(items[2], itemList[2].Item);
            Assert.AreEqual(16, itemList[2].Amount);

            itemList.Remove(items[0], 30);

            Assert.AreEqual(2, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(79, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(16, itemList[1].Amount);
            Assert.AreEqual(PKMN.Item.NONE, itemList[2].Item);
            Assert.AreEqual(0, itemList[2].Amount);

            itemList.Add(items[3], 90);

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(79, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(16, itemList[1].Amount);
            Assert.AreEqual(items[3], itemList[2].Item);
            Assert.AreEqual(90, itemList[2].Amount);

            itemList.Add(items[4], 2);

            Assert.AreEqual(4, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(79, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(16, itemList[1].Amount);
            Assert.AreEqual(items[3], itemList[2].Item);
            Assert.AreEqual(90, itemList[2].Amount);
            Assert.AreEqual(items[4], itemList[3].Item);
            Assert.AreEqual(2, itemList[3].Amount);

            itemList.Remove(items[1], 30);

            Assert.AreEqual(4, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(49, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(16, itemList[1].Amount);
            Assert.AreEqual(items[3], itemList[2].Item);
            Assert.AreEqual(90, itemList[2].Amount);
            Assert.AreEqual(items[4], itemList[3].Item);
            Assert.AreEqual(2, itemList[3].Amount);

            itemList.Add(items[5], 12);

            Assert.AreEqual(5, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(49, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(16, itemList[1].Amount);
            Assert.AreEqual(items[3], itemList[2].Item);
            Assert.AreEqual(90, itemList[2].Amount);
            Assert.AreEqual(items[4], itemList[3].Item);
            Assert.AreEqual(2, itemList[3].Amount);
            Assert.AreEqual(items[5], itemList[4].Item);
            Assert.AreEqual(12, itemList[4].Amount);

            itemList.Remove(items[2], 16);

            Assert.AreEqual(4, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(49, itemList[0].Amount);
            Assert.AreEqual(items[3], itemList[1].Item);
            Assert.AreEqual(90, itemList[1].Amount);
            Assert.AreEqual(items[4], itemList[2].Item);
            Assert.AreEqual(2, itemList[2].Amount);
            Assert.AreEqual(items[5], itemList[3].Item);
            Assert.AreEqual(12, itemList[3].Amount);

            itemList.Add(items[6], 65);

            Assert.AreEqual(5, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(49, itemList[0].Amount);
            Assert.AreEqual(items[3], itemList[1].Item);
            Assert.AreEqual(90, itemList[1].Amount);
            Assert.AreEqual(items[4], itemList[2].Item);
            Assert.AreEqual(2, itemList[2].Amount);
            Assert.AreEqual(items[5], itemList[3].Item);
            Assert.AreEqual(12, itemList[3].Amount);
            Assert.AreEqual(items[6], itemList[4].Item);
            Assert.AreEqual(65, itemList[4].Amount);

            itemList.Add(items[7], 6);

            Assert.AreEqual(6, itemList.NumItems);
            Assert.AreEqual(items[1], itemList[0].Item);
            Assert.AreEqual(49, itemList[0].Amount);
            Assert.AreEqual(items[3], itemList[1].Item);
            Assert.AreEqual(90, itemList[1].Amount);
            Assert.AreEqual(items[4], itemList[2].Item);
            Assert.AreEqual(2, itemList[2].Amount);
            Assert.AreEqual(items[5], itemList[3].Item);
            Assert.AreEqual(12, itemList[3].Amount);
            Assert.AreEqual(items[6], itemList[4].Item);
            Assert.AreEqual(65, itemList[4].Amount);
            Assert.AreEqual(items[7], itemList[5].Item);
            Assert.AreEqual(6, itemList[5].Amount);

            // Remove everything.
            itemList.Remove(items[1], 49);
            itemList.Remove(items[3], 90);
            itemList.Remove(items[4], 2);
            itemList.Remove(items[5], 12);
            itemList.Remove(items[6], 65);
            itemList.Remove(items[7], 6);

            Assert.AreEqual(0, itemList.NumItems);
            for (int itemIndex = 0; itemIndex < 8; ++itemIndex)
            {
                Assert.AreEqual(PKMN.Item.NONE, itemList[itemIndex].Item);
                Assert.AreEqual(0, itemList[itemIndex].Amount);
            }
        }
コード例 #25
0
        public static void KeyItemPocketTest(
            PKMN.ItemList keyItemPocket,
            PKMN.Game game
            )
        {
            int expectedLength = 0;

            if ((game == PKMN.Game.RUBY) || (game == PKMN.Game.SAPPHIRE))
            {
                expectedLength = 20;
            }
            else
            {
                expectedLength = 30;
            }

            // 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,
                PKMN.Item.BASEMENT_KEY
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                keyItemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.HM01,
                PKMN.Item.RAZZ_BERRY
            }
                );

            // 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.EIN_FILE_S,
                PKMN.Item.POWERUP_PART,
                PKMN.Item.GONZAPS_KEY,
                PKMN.Item.KRANE_MEMO_1
            }
                );
            if ((game == PKMN.Game.RUBY) || (game == PKMN.Game.SAPPHIRE))
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    keyItemPocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.HELIX_FOSSIL,
                    PKMN.Item.TEA,
                    PKMN.Item.RUBY
                }
                    );
            }
            if (game != PKMN.Game.EMERALD)
            {
                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.
            PKMN.Item[] validItems =
            {
                PKMN.Item.WAILMER_PAIL,
                PKMN.Item.BASEMENT_KEY,
                PKMN.Item.METEORITE,
                PKMN.Item.OLD_ROD,
                PKMN.Item.RED_ORB,
                PKMN.Item.ROOT_FOSSIL,
                PKMN.Item.CONTEST_PASS,
                PKMN.Item.EON_TICKET
            };
            ItemsTestsCommon.TestItemListSettingItems(
                keyItemPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                keyItemPocket,
                validItems
                );

            Assert.AreEqual(keyItemPocket.ValidItems.Count, keyItemPocket.ValidItemNames.Count);
            Assert.Greater(keyItemPocket.ValidItems.Count, 0);
        }
コード例 #26
0
        public static void KeyItemPocketTest(
            PKMN.ItemList keyItemPocket,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(keyItemPocket.Name, "KeyItems");
            Assert.AreEqual(keyItemPocket.Game, game);
            Assert.AreEqual(keyItemPocket.Length, 25);
            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,
                PKMN.Item.BICYCLE
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                keyItemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.HM01
            }
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                keyItemPocket,
                new PKMN.Item[]
            {
                PKMN.Item.MACH_BIKE,
                PKMN.Item.JADE_ORB,
                PKMN.Item.LIGHT_STONE,
                PKMN.Item.AQUA_SUIT
            }
                );

            // Crystal-specific items.
            if (game == PKMN.Game.CRYSTAL)
            {
                foreach (PKMN.Item crystalItem in CrystalItems)
                {
                    keyItemPocket.Add(crystalItem, 1);
                    keyItemPocket.Remove(crystalItem, 1);
                }

                Assert.AreEqual(keyItemPocket.NumItems, 0);
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    keyItemPocket,
                    CrystalItems
                    );
            }

            // Make sure we can't add or remove more than a single item.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                keyItemPocket.Add(PKMN.Item.BICYCLE, 5);
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                keyItemPocket.Remove(PKMN.Item.BICYCLE, 5);
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.BICYCLE,
                PKMN.Item.BASEMENT_KEY,
                PKMN.Item.SECRETPOTION,
                PKMN.Item.MYSTERY_EGG,
                PKMN.Item.SILVER_WING,
                PKMN.Item.LOST_ITEM,
                PKMN.Item.SQUIRT_BOTTLE,
                PKMN.Item.RAINBOW_WING
            };

            for (int itemIndex = 0; itemIndex < validItems.Length; ++itemIndex)
            {
                if (itemIndex < 4)
                {
                    keyItemPocket.Add(validItems[itemIndex], 1);
                }
                else
                {
                    keyItemPocket[itemIndex].Item = validItems[itemIndex];
                }
            }

            keyItemPocket.Remove(validItems[2], 1);
            keyItemPocket[2].Item = PKMN.Item.NONE;
            Assert.AreEqual(keyItemPocket.NumItems, 6);

            // Empty the rest for the bag test.
            while (keyItemPocket[0].Item != PKMN.Item.NONE)
            {
                keyItemPocket[0].Item = PKMN.Item.NONE;
            }

            Assert.AreEqual(keyItemPocket.ValidItems.Count, keyItemPocket.ValidItemNames.Count);
            Assert.Greater(keyItemPocket.ValidItems.Count, 0);
        }
コード例 #27
0
ファイル: GCNItemsTests.cs プロジェクト: ncorgan/libpkmn
        public static void ColognePocketTest(
            PKMN.ItemList colognePocket,
            PKMN.Game game
            )
        {
            bool colosseum      = (game == PKMN.Game.COLOSSEUM);
            int  expectedLength = 3;

            // Check unchanging and initial values.
            Assert.AreEqual(colognePocket.Name, "Colognes");
            Assert.AreEqual(colognePocket.Game, game);
            Assert.AreEqual(colognePocket.Length, expectedLength);
            Assert.AreEqual(colognePocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(colognePocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                colognePocket,
                PKMN.Item.JOY_SCENT
                );

            // Confirm items from other pockets can't be added.
            if (colosseum)
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    colognePocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.EIN_FILE_S,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY
                }
                    );
            }
            else
            {
                ItemsTestsCommon.TestItemListInvalidItems(
                    colognePocket,
                    new PKMN.Item[]
                {
                    PKMN.Item.GONZAPS_KEY,
                    PKMN.Item.POTION,
                    PKMN.Item.MASTER_BALL,
                    PKMN.Item.TM01,
                    PKMN.Item.ORAN_BERRY,
                    PKMN.Item.BATTLE_CD_01
                }
                    );
            }

            colognePocket.Add(PKMN.Item.JOY_SCENT, 3);
            colognePocket.Add(PKMN.Item.EXCITE_SCENT, 3);
            colognePocket.Add(PKMN.Item.VIVID_SCENT, 3);

            colognePocket.Remove(PKMN.Item.EXCITE_SCENT, 3);
            colognePocket.Remove(PKMN.Item.VIVID_SCENT, 1);

            Assert.AreEqual(colognePocket[0].Item, PKMN.Item.JOY_SCENT);
            Assert.AreEqual(colognePocket[0].Amount, 3);
            Assert.AreEqual(colognePocket[1].Item, PKMN.Item.VIVID_SCENT);
            Assert.AreEqual(colognePocket[1].Amount, 2);
            Assert.AreEqual(colognePocket[2].Item, PKMN.Item.NONE);
            Assert.AreEqual(colognePocket[2].Amount, 0);

            colognePocket.Remove(PKMN.Item.JOY_SCENT, 3);
            colognePocket.Remove(PKMN.Item.VIVID_SCENT, 2);

            Assert.AreEqual(colognePocket[0].Item, PKMN.Item.NONE);
            Assert.AreEqual(colognePocket[0].Amount, 0);
            Assert.AreEqual(colognePocket[1].Item, PKMN.Item.NONE);
            Assert.AreEqual(colognePocket[1].Amount, 0);
            Assert.AreEqual(colognePocket[2].Item, PKMN.Item.NONE);
            Assert.AreEqual(colognePocket[2].Amount, 0);

            Assert.AreEqual(colognePocket.ValidItems.Count, colognePocket.ValidItemNames.Count);
            Assert.AreEqual(colognePocket.ValidItems.Count, 3);
        }
コード例 #28
0
ファイル: ItemsTestsCommon.cs プロジェクト: ncorgan/libpkmn
        public static void TestItemListSettingItems(
            PKMN.ItemList itemList,
            PKMN.Item[] items
            )
        {
            Assert.AreEqual(0, itemList.NumItems);
            Assert.AreEqual(8, items.Length);

            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                itemList[-1].Item = items[0];
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                itemList[itemList.Length].Item = items[0];
            }
                );

            itemList[0].Item   = items[0];
            itemList[0].Amount = 50;
            itemList[1].Item   = items[1];
            itemList[1].Amount = 40;
            itemList[2].Item   = items[2];
            itemList[2].Amount = 30;

            Assert.AreEqual(3, itemList.NumItems);
            Assert.AreEqual(items[0], itemList[0].Item);
            Assert.AreEqual(50, itemList[0].Amount);
            Assert.AreEqual(items[1], itemList[1].Item);
            Assert.AreEqual(40, itemList[1].Amount);
            Assert.AreEqual(items[2], itemList[2].Item);
            Assert.AreEqual(30, itemList[2].Amount);

            // Make sure the item list being contiguous is enforced.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                itemList[10].Item = items[3];
            }
                );

            itemList[1].Item = PKMN.Item.NONE;

            Assert.AreEqual(2, itemList.NumItems);
            Assert.AreEqual(items[0], itemList[0].Item);
            Assert.AreEqual(50, itemList[0].Amount);
            Assert.AreEqual(items[2], itemList[1].Item);
            Assert.AreEqual(30, itemList[1].Amount);
            Assert.AreEqual(PKMN.Item.NONE, itemList[2].Item);
            Assert.AreEqual(0, itemList[2].Amount);

            itemList[0].Item = PKMN.Item.NONE;
            itemList[0].Item = PKMN.Item.NONE;

            Assert.AreEqual(0, itemList.NumItems);
            for (int itemIndex = 0; itemIndex < 3; ++itemIndex)
            {
                Assert.AreEqual(PKMN.Item.NONE, itemList[itemIndex].Item);
                Assert.AreEqual(0, itemList[itemIndex].Amount);
            }
        }
コード例 #29
0
        public static void BallPocketTest(
            PKMN.ItemList ballPocket,
            PKMN.Game game
            )
        {
            // Check unchanging and initial values.
            Assert.AreEqual(ballPocket.Name, "Balls");
            Assert.AreEqual(ballPocket.Game, game);
            Assert.AreEqual(ballPocket.Length, 12);
            Assert.AreEqual(ballPocket.NumItems, 0);

            // Make sure item slots start as correctly empty.
            ItemsTestsCommon.TestItemListEmptySlots(ballPocket);

            // Confirm exceptions are thrown when expected.
            ItemsTestsCommon.TestItemListIndexOutOfRangeException(
                ballPocket,
                PKMN.Item.MASTER_BALL
                );

            // Confirm items from other pockets can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                ballPocket,
                new PKMN.Item[]
            {
                PKMN.Item.POTION,
                PKMN.Item.BICYCLE,
                PKMN.Item.HM01
            }
                );

            // Confirm items from later generations can't be added.
            ItemsTestsCommon.TestItemListInvalidItems(
                ballPocket,
                new PKMN.Item[]
            {
                PKMN.Item.PREMIER_BALL,
                PKMN.Item.HEAL_BALL,
                PKMN.Item.DREAM_BALL
            }
                );

            // Start adding and removing stuff, and make sure the numbers are accurate.
            PKMN.Item[] validItems =
            {
                PKMN.Item.GREAT_BALL,
                PKMN.Item.POKE_BALL,
                PKMN.Item.PARK_BALL,
                PKMN.Item.FAST_BALL,
                PKMN.Item.MASTER_BALL,
                PKMN.Item.FRIEND_BALL,
                PKMN.Item.LOVE_BALL,
                PKMN.Item.LEVEL_BALL
            };
            ItemsTestsCommon.TestItemListSettingItems(
                ballPocket,
                validItems
                );
            ItemsTestsCommon.TestItemListAddingAndRemovingItems(
                ballPocket,
                validItems
                );

            Assert.AreEqual(ballPocket.ValidItems.Count, ballPocket.ValidItemNames.Count);
            Assert.Greater(ballPocket.ValidItems.Count, 0);
        }