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

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

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

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

            Assert.NotNull(actionResult);
            Assert.Equal(ID_TO_FIND, actionResult.Value.Id);
        }
Exemple #3
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 #4
0
        public async void TestStrokeAnimalAppropriate()
        {
            var controller  = new MediatonicTestController(context);
            var ownedAnimal = await controller.GetAnimal(ID_TO_FIND);

            int initialHappiness = ownedAnimal.Value.Happiness;

            ownedAnimal = await controller.StrokeAnimal(ID_TO_FIND);

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

            Assert.Equal(initialHappiness + 1, actionResult.Value.Happiness);
        }
Exemple #5
0
        public async void TestGetAnimalCreatedInThePast()
        {
            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);

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

            Assert.NotNull(actionResult);
            Assert.Equal(ID_OF_ANIMAL_CREATED_IN_PAST, actionResult.Value.Id);

            animalOwnership = context.AnimalOwnership.Find(ID_OF_ANIMAL_CREATED_IN_PAST);
            Assert.Equal(DateTime.Now.Year, animalOwnership.LastUpdated.Year);
        }
Exemple #6
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);
        }
Exemple #7
0
        public async void TestGetAnimalDegradation()
        {
            var      controller      = new MediatonicTestController(context);
            var      animalOwnership = context.AnimalOwnership.Find(ID_OF_ANIMAL_CREATED_IN_PAST_BY_AN_HOUR);
            DateTime updatedTime     = animalOwnership.LastUpdated;

            Assert.Equal(DateTime.Now.Hour - 1, updatedTime.Hour);
            var animal = context.Animal.Find(animalOwnership.AnimalId);

            //Assert current state is equal to defaults
            Assert.Equal(MOCK_ANIMAL_DEFAULT_HAPPINESS, animalOwnership.Happiness);
            Assert.Equal(MOCK_ANIMAL_DEFAULT_HUNGER, animalOwnership.Hunger);

            var ownedAnimal = await controller.GetAnimal(ID_OF_ANIMAL_CREATED_IN_PAST_BY_AN_HOUR);

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

            Assert.NotNull(actionResult);
            Assert.Equal(ID_OF_ANIMAL_CREATED_IN_PAST_BY_AN_HOUR, actionResult.Value.Id);
            Assert.Equal(MOCK_ANIMAL_DEFAULT_HUNGER + animal.HungerIncrease, ownedAnimal.Value.Hunger);
            Assert.Equal(MOCK_ANIMAL_DEFAULT_HAPPINESS - animal.HappinessDecrease, ownedAnimal.Value.Happiness);
        }