Exemplo n.º 1
0
        public IEnumerable <AnimalTypeDTO> GetAnimalTypes()
        {
            IEnumerable <AnimalType>    response    = animalTypeRepository.GetAnimalTypes();
            IEnumerable <AnimalTypeDTO> returnValue = Mapper.Map <IEnumerable <AnimalTypeDTO> >(response);

            return(returnValue);
        }
        public void GetAnimals_ShouldReturnAnimals_WhenNoId()
        {
            List <AnimalType> animalTypes = animalTypeRepository.GetAnimalTypes().ToList();

            Assert.AreEqual(mockAnimalTypes.Count, animalTypes.Count);
            Assert.IsTrue(mockAnimalTypes.SequenceEqual(animalTypes));

            AnimalType updatedAnimalType = new AnimalType()
            {
                Id                     = 1,
                AnimalTypeName         = "Doggy",
                HappinessDeductionRate = 9,
                HungerIncreaseRate     = 8
            };

            animalTypeRepository.UpdateAnimalType(1, updatedAnimalType);

            animalTypes = animalTypeRepository.GetAnimalTypes().ToList();

            //When a value is amended, the Repo should maintian order by Id
            for (int i = 0; i < mockAnimalTypes.Count; i++)
            {
                Assert.AreEqual(i + 1, animalTypes[i].Id);
            }
        }