Example #1
0
        public void GetAnimals_Return_NotNullResult()
        {
            // Act
            var actionResult = controller.GetAnimals() as IHttpActionResult;

            // Assert
            Assert.IsNotNull(actionResult);
        }
Example #2
0
        public void GetAnimalsTestWithAnimals()
        {
            List <Animal> animalList = new List <Animal>();

            animalList.Add(new Sheep(0, "Dory", 0));
            animalList.Add(new Sheep(1, "Clone", 0));

            var mockGet = new Mock <IGetDataServices>();

            mockGet.Setup(repo => repo.GetAnimals()).Returns(animalList);

            var mockSet = new Mock <ISetDataServices>();

            mockSet.Setup(m => m.UpdateAnimals(animalList)).Returns(animalList);

            // arrange
            var controller = new AnimalsController(mockGet.Object, mockSet.Object);

            // act
            var result   = controller.GetAnimals();
            var okResult = result as OkObjectResult;

            // assert
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
            Assert.ReferenceEquals(animalList, okResult.Value);
        }
Example #3
0
        public async Task TestGetAllAnimal()
        {
            var controller = new AnimalsController(context);
            var animals    = await controller.GetAnimals();

            Assert.Equal(EXPECTED_SIZE_OF_ALL, animals.Value.Count());
        }
Example #4
0
        public void GetAnimalsTestWithoutAnimals()
        {
            // arrange
            var mockGet = new Mock <IGetDataServices>();

            mockGet.Setup(repo => repo.GetAnimals()).Returns(new List <Animal>());

            var mockSet = new Mock <ISetDataServices>();

            mockSet.Setup(m => m.UpdateAnimals(new List <Animal>())).Returns(new List <Animal>());

            // arrange
            var controller = new AnimalsController(mockGet.Object, mockSet.Object);

            // act
            var result   = controller.GetAnimals();
            var okResult = result as OkObjectResult;

            // assert
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
            Assert.AreEqual("There is no animals yet", okResult.Value);
        }