public void DeleteAnimalType(int id) { AnimalType animalType = null; try { // I don't need to convert to a DTO therefore am calling repo rather than manager animalType = animalTypeRepository.GetAnimalTypeById(id); } //I am using .First therefore it can throw Exceptions //FirstOrDefault returns in the Default Value therefore am not using catch (InvalidOperationException) { //Handled in controller throw; } if (animalType != null) { animalTypeRepository.DeleteAnimalType(animalType); } else //Internal Server Error { throw new Exception(); } }
public void GetAnimalTypesById_ShouldReturnAnimalTypes_WhenValidId() { AnimalType animalType = animalTypeRepository.GetAnimalTypeById(1); Assert.ReferenceEquals(mockAnimalTypes[0], animalType); }