示例#1
0
        public void StowIStowable_Null_Throws()
        {
            // Arrange
            var character = Mock.Of <ICharacter>();
            EquipmentSection equipmentSection = new EquipmentSection(character);
            IStowable        item             = null;

            // Act
            TestDelegate stow = () => equipmentSection.Stow(item);

            // Assert
            Assert.Throws <ArgumentNullException>(stow);
        }
示例#2
0
        public void StowIStowable_Twice_Throws()
        {
            // Arrange
            var character = Mock.Of <ICharacter>();
            var item      = Mock.Of <IStowable>();
            EquipmentSection equipmentSection = new EquipmentSection(character);

            // Act
            TestDelegate stow = () => equipmentSection.Stow(item);

            // Assert
            Assert.DoesNotThrow(stow);                       // No exception is thrown the first time
            Assert.Throws <InvalidOperationException>(stow); // Throws the second time
        }
示例#3
0
        public void StowIStowable_HappyPath()
        {
            // Arrange
            var character = Mock.Of <ICharacter>();
            var item      = Mock.Of <IStowable>();
            EquipmentSection equipmentSection = new EquipmentSection(character);

            // Act
            equipmentSection.Stow(item);

            // Assert
            Assert.Contains(item, equipmentSection.GetInventory(),
                            "Stowing an item should create a reference in the equipment section's GetInventory collection.");
            Mock.Get(item)
            .Verify(i => i.ApplyTo(It.Is <ICharacter>(c => c == character)),
                    "Stowing the item should call the item's .ApplyTo method, passing in the character as an argument.");
        }
示例#4
0
        public void StowSpellbook_HappyPath()
        {
            // Arrange
            var character = Mock.Of <ICharacter>();
            var spellbook = Mock.Of <ISpellbook>();
            EquipmentSection equipmentSection = new EquipmentSection(character);

            // Act
            equipmentSection.Stow(spellbook);

            // Assert
            Assert.AreSame(spellbook, equipmentSection.Spellbook,
                           "Stowing a spellbook should create a reference in the equipment section's Spellbook slot.");
            Mock.Get(spellbook)
            .Verify(s => s.ApplyTo(It.Is <ICharacter>(c => c == character)),
                    "Stowing the item should call the item's .ApplyTo method, passing in the character as an argument.");
        }