public void CreateCreature_ShouldThrow_IfPassedStringIsNullOrEmpty() { // Arrange var creatureTypeName = string.Empty; var creaturesFactory = new CreaturesFactory(); // Act and Assert var resultingException = Assert.Throws <ArgumentNullException>(() => creaturesFactory.CreateCreature(creatureTypeName)); Assert.IsTrue(resultingException.Message.Contains("Creature Name is null or empty")); }
public void CreateCreature_ShouldThrow_IfPassedAStringWithAnUnexistingType() { // Arrange var creatureTypeName = "unexisting type"; var creaturesFactory = new CreaturesFactory(); // Act and Assert var resultingException = Assert.Throws <ArgumentException>(() => creaturesFactory.CreateCreature(creatureTypeName)); Assert.IsTrue(resultingException.Message.Contains("Invalid creature type")); }
public void CreateCreature_CreatesAnInstanceOfTheCorrectType(string creatureTypeName, Type expectedType) { // Arrange var creaturesFactory = new CreaturesFactory(); // Act var resultingInstance = creaturesFactory.CreateCreature(creatureTypeName); var actualInstanceType = resultingInstance.GetType(); // Assert Assert.AreEqual(expectedType, actualInstanceType); }