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

            animal.Id   = EXPECTED_SIZE_OF_ALL + 1;
            animal.Type = CHANGED_TEXT;
            var newAnimal = await controller.PostAnimal(animal);

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

            Assert.IsType <CreatedAtActionResult>(actionResult.Result);
            Assert.NotNull(actionResult);
            long expectedSize = EXPECTED_SIZE_OF_ALL + 1;

            animal = context.Animal.Find(expectedSize);
            Assert.Equal(CHANGED_TEXT, animal.Type);
            Assert.Equal(expectedSize, animal.Id);
        }