Esempio n. 1
0
        public async Task TestPutAnimalInappropriateId()
        {
            var    controller = new AnimalsController(context);
            Animal animal     = context.Animal.Find(ID_TO_FIND);

            var modifiedOwnedAnimal = await controller.PutAnimal(INAPPROPRIATE_ID_TO_FIND, animal);

            // Assert
            var actionResult = Assert.IsType <ActionResult <Animal> >(modifiedOwnedAnimal);

            Assert.IsType <BadRequestResult>(actionResult.Result);
        }
Esempio n. 2
0
        public async Task TestPutAnimalAppropriateId()
        {
            var    controller = new AnimalsController(context);
            Animal animal     = context.Animal.Find(ID_TO_FIND);

            animal.Type = CHANGED_TEXT;

            var modifiedAnimal = await controller.PutAnimal(animal.Id, animal);

            var actionResult = Assert.IsType <ActionResult <Animal> >(modifiedAnimal);

            Assert.NotNull(actionResult);
            Assert.Equal(CHANGED_TEXT, actionResult.Value.Type);
            animal = context.Animal.Find(ID_TO_FIND);
            Assert.Equal(CHANGED_TEXT, animal.Type);
        }