Exemple #1
0
        public async void TestFeedAnimalInappropriate()
        {
            var controller  = new MediatonicTestController(context);
            var ownedAnimal = await controller.FeedAnimal(INAPPROPRIATE_ID_TO_FIND);

            var actionResult = Assert.IsType <ActionResult <OwnedAnimal> >(ownedAnimal);

            Assert.IsType <BadRequestResult>(actionResult.Result);
        }
Exemple #2
0
        public async void TestFeedAnimalAppropriate()
        {
            var controller  = new MediatonicTestController(context);
            var ownedAnimal = await controller.GetAnimal(ID_TO_FIND);

            int initialHunger = ownedAnimal.Value.Hunger;

            ownedAnimal = await controller.FeedAnimal(ID_TO_FIND);

            var actionResult = Assert.IsType <ActionResult <OwnedAnimal> >(ownedAnimal);

            Assert.Equal(initialHunger - 1, actionResult.Value.Hunger);
        }
Exemple #3
0
        public async void TestFeedAnimalCreatedInPast()
        {
            var controller      = new MediatonicTestController(context);
            var animalOwnership = context.AnimalOwnership.Find(ID_OF_ANIMAL_CREATED_IN_PAST);

            Assert.Equal(db.PAST_CREATION_DATE, animalOwnership.LastUpdated);

            var ownedAnimal = await controller.GetAnimal(ID_OF_ANIMAL_CREATED_IN_PAST);

            int initialHunger = ownedAnimal.Value.Hunger;

            ownedAnimal = await controller.FeedAnimal(ID_TO_FIND);

            var actionResult = Assert.IsType <ActionResult <OwnedAnimal> >(ownedAnimal);

            Assert.Equal(initialHunger - 1, actionResult.Value.Hunger);

            animalOwnership = context.AnimalOwnership.Find(ID_OF_ANIMAL_CREATED_IN_PAST);
            Assert.Equal(DateTime.Now.Year, animalOwnership.LastUpdated.Year);
        }