/// <summary> /// Remove a certain animal from the zoo. /// </summary> /// <param name="name"></param> /// <exception cref="ArgumentException"></exception> public void RemoveAnimal(MamalAnimal animal) { if (Animals.Contains(animal)) { Animals.Remove(animal); } else { throw new ArgumentException(); } }
/// <summary> /// Add a certain mamal animal to the zoo. /// </summary> /// <param name="animal"></param> /// <exception cref="ArgumentException"></exception> public void AddAnimal(MamalAnimal animal) { if (animal is MamalAnimal) { Animals.Add(animal); } else { throw new ArgumentException(); } }
public void MamalAnimal_WhenInitWithOutOfRangeHealth_Return_Exeption(int health, bool isExceptionExpected) { // Arrange bool isExceptionActual = false; // Act try { MamalAnimal animal = new MamalAnimal(name: "Animal", age: 10, health: health, id: Guid.NewGuid()); } catch { isExceptionActual = true; } // Assert Assert.Equal(isExceptionExpected, isExceptionActual); }
public void MamalAnimal_WhenInitWithNonpositiveAge_Return_Exception(int animalAge, bool isExceptionExpected) { // Arrange bool isExceptionActual = false; // Act try { MamalAnimal animal = new MamalAnimal(name: "Animal", age: animalAge, health: 100, id: Guid.NewGuid()); } catch { isExceptionActual = true; } // Assert Assert.Equal(isExceptionExpected, isExceptionActual); }
public void MamalAnimal_WhenInitWithNullName_Return_Exeption() { // Arrange // --- Defaul MAX_AGE = 25; string name = null; bool isException = false; // Act try { MamalAnimal animal = new MamalAnimal(name: name, age: 10, health: 100, id: Guid.NewGuid()); } catch { isException = true; } // Assert Assert.True(isException); }
public void MamalAnimal_WhenInitWithAgeGreaterThenMaxAge_Return_Exception() { // Arrange // --- Defaul MAX_AGE = 25; int age = 30; bool isException = false; // Act try { MamalAnimal animal = new MamalAnimal(name: "Animal", age: age, health: 100, id: Guid.NewGuid()); } catch { isException = true; } // Assert Assert.True(isException); }