public async void TestStrokeAnimalInappropriate() { var controller = new MediatonicTestController(context); var ownedAnimal = await controller.StrokeAnimal(INAPPROPRIATE_ID_TO_FIND); var actionResult = Assert.IsType <ActionResult <OwnedAnimal> >(ownedAnimal); Assert.IsType <BadRequestResult>(actionResult.Result); }
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); }
public async void TestStrokeAnimalCreatedInPast() { 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 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); animalOwnership = context.AnimalOwnership.Find(ID_OF_ANIMAL_CREATED_IN_PAST); Assert.Equal(DateTime.Now.Year, animalOwnership.LastUpdated.Year); }