public async Task Get_WhenCall_ReturnOkResult()
        {
            // Act
            var result = await _controller.Get();

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);
            // await Assert.IsType<Task<OkObjectResult>>(okResult);
        }
Beispiel #2
0
        public void Get_ShouldReturnIENumerableAnimalDTO_WhenValidUserId()
        {
            var result               = animalController.Get(1);
            var response             = result as OkObjectResult;
            var responseValue        = response.Value as IEnumerable <AnimalDTO>;
            List <AnimalDTO> animals = responseValue.ToList();

            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(mockAnimals.Count, animals.Count);
            Assert.AreEqual(1, animals[0].Id);
            Assert.AreEqual(2, animals[1].Id);
        }
            public void Happiness_of_a_dog_increases_by_1_when_petted()
            {
                //arrange

                const string dogName = "eddy";

                //act
                pettingController.Pet(new AnimalIdentifier(UserId, dogName));


                //assert
                var animal = animalController.Get(UserId, dogName);

                animal.Happiness.Should().Be(2);
            }
        public void Can_retrieve_a_animal()
        {
            //arrange
            const string      animalName = "Tom";
            const string      owner      = "*****@*****.**";
            const AnimalTypes type       = AnimalTypes.Cat;

            var repository = new InMemoryAnimalRepository(AnimalDataUtilities.AnimalData(owner));
            var service    = new AnimalFindService(repository);
            var controller = new AnimalController(service);

            //act
            var animal = controller.Get(owner, animalName);



            //Assert
            animal.Name.Should().Be(animalName);
            animal.Owner.Should().Be(owner);
            animal.Type.Should().Be(type);
        }
Beispiel #5
0
        public void GetAnimals_ReturnsAllAnimals()
        {
            var testAnimalService = new TestAnimalService
            {
                Animals = new List <Animal>
                {
                    new Animal {
                        Name = "TestAnimal", Description = "Not a real animal."
                    }
                }
            };
            var animalController = new AnimalController(testAnimalService);

            var response = animalController.Get();

            Assert.Equal(
                new List <Animal> {
                new Animal {
                    Name = "TestAnimal", Description = "Not a real animal."
                }
            },
                response
                );
        }
Beispiel #6
0
        public void GetAnimalsList()
        {
            IEnumerable <Animal> animals = controller.Get(null);

            Assert.Equal(8, animals.Count());
        }
            public void Feeding_lizard_reduces_hunger_by_5()
            {
                //arrange
                const string LizardName = "tails";

                //check precondition
                var lizardReference1 = animalController.Get(UserId, LizardName);

                lizardReference1.Hunger.Should().Be(0);

                //act
                feedingController.Feed(new AnimalIdentifier(UserId, LizardName));

                //assert
                var lizardReference2 = animalController.Get(UserId, LizardName);

                lizardReference2.Hunger.Should().Be(-5);
            }