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); }
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 }
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."); }
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."); }