Beispiel #1
0
        public AnimalTypeCreatedDTO CreateAnimalType(AnimalTypeCreationDTO animalTypeCreationDTO)
        {
            AnimalType animalType = Mapper.Map <AnimalType>(animalTypeCreationDTO);

            animalType.Id = GetNextId();

            AnimalType result = animalTypeRepository.CreateAnimalType(animalType);

            AnimalTypeCreatedDTO returnValue = Mapper.Map <AnimalTypeCreatedDTO>(result);

            return(returnValue);
        }
        public void AddAnimalType_ShouldAddAnimalType_WhenValid()
        {
            AnimalType animalType = new AnimalType()
            {
                Id                     = 3,
                AnimalTypeName         = "Donkey",
                HappinessDeductionRate = 5,
                HungerIncreaseRate     = 3
            };

            int animalCount = animalTypeRepository.GetAnimalTypes().Count();

            AnimalType returnValue = animalTypeRepository.CreateAnimalType(animalType);

            Assert.AreEqual(2, animalCount);
            animalCount = animalTypeRepository.GetAnimalTypes().Count();
            Assert.AreEqual(3, animalCount);
            Assert.AreEqual(animalType.Id, returnValue.Id);
            Assert.AreEqual(animalType.AnimalTypeName, returnValue.AnimalTypeName);
            Assert.AreEqual(animalType.HappinessDeductionRate, returnValue.HappinessDeductionRate);
            Assert.AreEqual(animalType.HungerIncreaseRate, returnValue.HungerIncreaseRate);
        }