예제 #1
0
        public void PotionBagOnlyAllowsPotions()
        {
            var bag = new PotionSatchel();

            Assert.IsTrue(bag.AddItem(new HealingPotion()));
            Assert.IsFalse(bag.AddItem(new GreatAxe()));
        }
예제 #2
0
        public void PotionSatchelRequiresPotions()
        {
            PotionSatchel p = new PotionSatchel();
            HealthPotion  h = new HealthPotion();
            GreatAxe      g = new GreatAxe();

            Assert.AreEqual(AddItemStatus.Ok, p.AddItem(h));
            Assert.AreEqual(AddItemStatus.ItemWrongType, p.AddItem(g));
        }
예제 #3
0
        public static void SpecificContainerDemo()
        {
            // created a container that will only allow a specific type of item
            // this container only holds potions
            PotionSatchel potions = new PotionSatchel();

            // adding a potion is fine and returns true
            Console.WriteLine($"Adding Healing Potion: {potions.AddItem(new HealingPotion())}");

            // adding a non potion item fails and returns false in this case
            Console.WriteLine($"Adding Short Sword: {potions.AddItem(new ShortSword())}");
        }
예제 #4
0
        public void PotionSatchelOnlyAllowsPotions()
        {
            PotionSatchel ps  = new PotionSatchel();
            GreatAxe      axe = new GreatAxe();
            HealthPotion  p   = new HealthPotion();

            AddItemStatus result = ps.AddItem(axe);

            Assert.AreEqual(AddItemStatus.ItemNotRightType, result);

            result = ps.AddItem(p);
            Assert.AreEqual(AddItemStatus.Success, result);
        }
예제 #5
0
        public void PotionSatchelOnlyAllowsPotions()
        {
            PotionSatchel satchel = new PotionSatchel();
            GreatAxe      axe     = new GreatAxe();

            bool result = satchel.AddItem(axe);

            Assert.AreEqual(false, result);

            HealthPotion potion = new HealthPotion();

            result = satchel.AddItem(potion);
            Assert.AreEqual(true, result);
        }
예제 #6
0
        public void PotionSatchelOnlyAllowsPotions()
        {
            PotionSatchel satchel    = new PotionSatchel();
            Sword         steelsword = new Sword();

            AddItemStatus result = satchel.AddItem(steelsword);

            Assert.AreEqual(AddItemStatus.ItemNotRightType, result);

            HealthPotion potion = new HealthPotion();

            result = satchel.AddItem(potion);
            Assert.AreEqual(AddItemStatus.Success, result);
        }
예제 #7
0
        public void PotionSatchelOnlyAllowsPotions()
        {
            PotionSatchel satchel = new PotionSatchel();
            GreatAxe      axe     = new GreatAxe();

            AddItemStatus result = satchel.AddItem(axe);

            Assert.AreEqual(AddItemStatus.ItemWrongType, result);

            HealthPotion potion = new HealthPotion();

            result = satchel.AddItem(potion);
            Assert.AreEqual(AddItemStatus.Success, result);
        }
        public void PotionSatchelOnlyAllowsPotions()
        {
            PotionSatchel satchel = new PotionSatchel();
            TurtleArmor   armor   = new TurtleArmor();

            AddItemStatus result = satchel.AddItem(armor);

            Assert.AreEqual(AddItemStatus.ItemNotRightType, result);

            HealthPotion potion = new HealthPotion();

            result = satchel.AddItem(potion);
            Assert.AreEqual(AddItemStatus.Success, result);
        }
예제 #9
0
        public void RequiredItemType()
        {
            PotionSatchel b = new PotionSatchel();
            Sword         s = new Sword();

            var actual = b.AddItem(s);

            Assert.AreEqual(AddItemStatus.ItemWrongType, actual);

            HealthPotion hp = new HealthPotion();

            actual = b.AddItem(hp);

            Assert.AreEqual(AddItemStatus.Ok, actual);
        }
예제 #10
0
        public void CannotAddNonPoitionsToPotionSatchel()
        {
            PotionSatchel container     = new PotionSatchel();
            GreatAxe      wrongItemType = new GreatAxe();

            AddItemStatus result = container.AddItem(wrongItemType);

            Assert.AreEqual(result, AddItemStatus.ItemWrongType);
        }