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); }
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); }
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); }
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 void TestGetAnimalsForUser() { var controller = new MediatonicTestController(context); IEnumerable <OwnedAnimal> ownedAnimals = controller.GetAnimalsForUser(ID_TO_FIND); int i = 0; foreach (OwnedAnimal animal in ownedAnimals) { i++; } Assert.Equal(EXPECTED_SIZE_PER_USER, i); }
public void TestGetAllOwnedAnimals() { var controller = new MediatonicTestController(context); IEnumerable <OwnedAnimal> ownedAnimals = controller.Get(); int i = 0; foreach (OwnedAnimal animal in ownedAnimals) { i++; } Assert.Equal(EXPECTED_SIZE_OF_ALL, i); }
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); }
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); }
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); }