public void TestPickUpItem() { // prepare map block with one item, player and pick up action MapBlock mapBlock = new MapBlock(0, 0); AbstractInventoryItem item = new BasicItem("Test item", mapBlock, 10); mapBlock.Item = item; AbstractPlayer testPlayer = new EmptyAIPlayer("Test player", mapBlock); PickUp pickUpAction = new PickUp() { Actor = testPlayer }; // check that inventory is empty Assert.AreEqual(0, testPlayer.Inventory.Count, "Inventory should be empty!"); Assert.IsNotNull(mapBlock.Item, "Item should be placed in map block!"); // perform pick up action pickUpAction.Execute(); // check that item was picked up Assert.AreEqual(1, testPlayer.Inventory.Count, "There should be one item in inventory!"); Assert.IsNull(mapBlock.Item, "There should be no item in the map block!"); Assert.AreEqual(item, testPlayer.GetItemFromInventory(0), "Wrong item picked up!"); }
public void TestPickUpNoItem() { // prepare map block, player and pick up action MapBlock mapBlock = new MapBlock(0, 0); AbstractPlayer testPlayer = new EmptyAIPlayer("Test player", mapBlock); PickUp pickUpAction = new PickUp() { Actor = testPlayer }; // perform pick up action pickUpAction.Execute(); }
public void TestPickUpWeapon() { // prepare map block with one item, player and pick up action MapBlock mapBlock = new MapBlock(0, 0); AbstractItem sword = new Axe(mapBlock); mapBlock.Item = sword; AbstractPlayer testPlayer = new EmptyAIPlayer("Test player", mapBlock); PickUp pickUpAction = new PickUp() { Actor = testPlayer }; // check that player has no weapon Assert.IsNull(testPlayer.Weapon, "No weapon should be equipped!"); // perform pick up action pickUpAction.Execute(); // check that weapon was equipped Assert.IsNotNull(testPlayer.Weapon, "Weapon should be equipped!"); Assert.AreEqual(sword, testPlayer.Weapon, "Wrong weapon picked up"); Assert.IsNull(mapBlock.Item, "Item was not picked up from map block"); // add new sword to the map block and check that swapping works AbstractItem sword2 = new Axe(mapBlock); mapBlock.Item = sword2; pickUpAction.Execute(); // check swap Assert.IsNotNull(testPlayer.Weapon, "Weapon should be equipped!"); Assert.AreEqual(sword2, testPlayer.Weapon, "Wrong weapon picked up!"); Assert.IsNotNull(mapBlock.Item, "First sword should be placed back to map block!"); Assert.AreEqual(sword, mapBlock.Item, "Wrong sword placed in map block!"); }
public void TestPickUpArmor() { // prepare map block with one item, player and pick up action MapBlock mapBlock = new MapBlock(0, 0); AbstractItem armor = new LeatherArmor(mapBlock); mapBlock.Item = armor; AbstractPlayer testPlayer = new EmptyAIPlayer("Test player", mapBlock); PickUp pickUpAction = new PickUp() { Actor = testPlayer }; // check that player has no armor Assert.IsNull(testPlayer.Armor, "No armor should be equipped!"); // perform pick up action pickUpAction.Execute(); // check that armor was equipped Assert.IsNotNull(testPlayer.Armor, "Armor should be equipped!"); Assert.AreEqual(armor, testPlayer.Armor, "Wrong armor picked up"); Assert.IsNull(mapBlock.Item, "Item was not picked up from map block"); // add new sword to the map block and check that swapping works AbstractItem armor2 = new LeatherArmor(mapBlock); mapBlock.Item = armor2; pickUpAction.Execute(); // check swap Assert.IsNotNull(testPlayer.Armor, "Amor should be equipped!"); Assert.AreEqual(armor2, testPlayer.Armor, "Wrong armor picked up!"); Assert.IsNotNull(mapBlock.Item, "First armor should be placed back to map block!"); Assert.AreEqual(armor, mapBlock.Item, "Wrong armor placed in map block!"); }
public void TestPickUpFullInventory() { // prepare map block with one item, player and pick up action MapBlock mapBlock = new MapBlock(0, 0); AbstractInventoryItem item = new BasicItem("Test item", mapBlock, 10); mapBlock.Item = item; AbstractPlayer testPlayer = new FullInventoryPlayer("Test player", mapBlock); PickUp pickUpAction = new PickUp() { Actor = testPlayer }; // perform pickup action pickUpAction.Execute(); }