Exemplo n.º 1
0
        public void DeleteNullGymWrongIdReturns404()
        {
            // Arrange
            var gymsRepo   = new Mock <IGymRepository>();
            var services   = new Mock <IPaginationUtilities>();
            var controller = new GymApiController(gymsRepo.Object, services.Object)
            {
                ControllerContext = { HttpContext = new DefaultHttpContext() }
            };

            // Act
            var deelteResponse = controller.Delete(404);

            // Assert
            Assert.Equal(404, controller.Response.StatusCode);
            Assert.IsType(typeof(JsonResult), deelteResponse);
        }
Exemplo n.º 2
0
        public void DeleteValidGymValidIdErrorDuringReturnsBadRequest()
        {
            // Arrange
            var gym      = TestEntities.Gyms[0];
            var gymsRepo = new Mock <IGymRepository>();

            gymsRepo.Setup(repo => repo.Get(gym.Id)).Returns(gym);
            gymsRepo.Setup(repo => repo.Delete(gym)).Returns(false);
            var services   = new Mock <IPaginationUtilities>();
            var controller = new GymApiController(gymsRepo.Object, services.Object)
            {
                ControllerContext = { HttpContext = new DefaultHttpContext() }
            };
            // Act
            var deelteResponse = controller.Delete(gym.Id);

            // Assert
            Assert.IsType(typeof(BadRequestObjectResult), deelteResponse);
        }