public void EquipingThirdRing_Throws() { // Arrange var character = Mock.Of <ICharacter>(); var ring1 = Mock.Of <IRingSlot>(); var ring2 = Mock.Of <IRingSlot>(); var ring3 = Mock.Of <IRingSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act TestDelegate firstEquip = () => equipmentSection.Equip(ring1); TestDelegate secondEquip = () => equipmentSection.Equip(ring2); TestDelegate thirdEquip = () => equipmentSection.Equip(ring3); // Assert Assert.DoesNotThrow(firstEquip); // No exception is thrown the first time Assert.DoesNotThrow(secondEquip); // ...or the second time... Assert.Throws <InvalidOperationException>(thirdEquip); // But the third time is forbidden. }
public void EquipHeadband_Null_Throws() { // Arrange var character = Mock.Of <ICharacter>(); EquipmentSection equipmentSection = new EquipmentSection(character); IHeadbandSlot headband = null; // Act TestDelegate equip = () => equipmentSection.Equip(headband); // Assert Assert.Throws <ArgumentNullException>(equip); }
public void EquipRing_Null_Throws() { // Arrange var character = Mock.Of <ICharacter>(); EquipmentSection equipmentSection = new EquipmentSection(character); IRingSlot ring = null; // Act TestDelegate equip = () => equipmentSection.Equip(ring); // Assert Assert.Throws <ArgumentNullException>(equip); }
public void EquipShoulders_Null_Throws() { // Arrange var character = Mock.Of <ICharacter>(); EquipmentSection equipmentSection = new EquipmentSection(character); IShouldersSlot shoulders = null; // Act TestDelegate equip = () => equipmentSection.Equip(shoulders); // Assert Assert.Throws <ArgumentNullException>(equip); }
public void EquipArmor_Twice_Throws() { // Arrange var character = Mock.Of <ICharacter>(); var armor = Mock.Of <IArmorSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act TestDelegate equip = () => equipmentSection.Equip(armor); // Assert Assert.DoesNotThrow(equip); // No exception is thrown the first time Assert.Throws <InvalidOperationException>(equip); // Throws the second time }
public void EquipRings_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var ring1 = Mock.Of <IRingSlot>(); var ring2 = Mock.Of <IRingSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(ring1); equipmentSection.Equip(ring2); // Assert Assert.AreSame(ring1, equipmentSection.Rings.Item1, "The first equipped ring should be stored in the first ring slot."); Assert.AreSame(ring2, equipmentSection.Rings.Item2, "The second equipped ring should be stored in the first ring slot."); Mock.Get(ring1) .Verify(r => r.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); Mock.Get(ring2) .Verify(r => r.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipArmor_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var armor = Mock.Of <IArmorSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(armor); // Assert Assert.AreSame(armor, equipmentSection.Armor, "Equipping armor should create a reference in the equipment section's Armor slot."); Mock.Get(armor) .Verify(a => a.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipWrists_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var wrists = Mock.Of <IWristsSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(wrists); // Assert Assert.AreSame(wrists, equipmentSection.Wrists, "Equipping wrists should create a reference in the equipment section's Wrists slot."); Mock.Get(wrists) .Verify(w => w.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipShield_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var shield = Mock.Of <IShieldSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(shield); // Assert Assert.AreSame(shield, equipmentSection.Shield, "Equipping a shield should create a reference in the equipment section's Shield slot."); Mock.Get(shield) .Verify(s => s.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipNeck_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var neck = Mock.Of <INeckSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(neck); // Assert Assert.AreSame(neck, equipmentSection.Neck, "Equipping a neck should create a reference in the equipment section's Neck slot."); Mock.Get(neck) .Verify(n => n.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipHeadband_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var headband = Mock.Of <IHeadbandSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(headband); // Assert Assert.AreSame(headband, equipmentSection.Headband, "Equipping a headband should create a reference in the equipment section's Headband slot."); Mock.Get(headband) .Verify(h => h.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipFeet_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var feet = Mock.Of <IFeetSlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(feet); // Assert Assert.AreSame(feet, equipmentSection.Feet, "Equipping feet should create a reference in the equipment section's Feet slot."); Mock.Get(feet) .Verify(f => f.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }
public void EquipBody_HappyPath() { // Arrange var character = Mock.Of <ICharacter>(); var body = Mock.Of <IBodySlot>(); EquipmentSection equipmentSection = new EquipmentSection(character); // Act equipmentSection.Equip(body); // Assert Assert.AreSame(body, equipmentSection.Body, "Equipping a body should create a reference in the equipment section's Body slot."); Mock.Get(body) .Verify(b => b.ApplyTo(It.Is <ICharacter>(c => c == character)), "Equipping the item should call the item's .ApplyTo method, passing in the character as an argument."); }