Beispiel #1
0
        public async Task Remove_NotExistingIdPassed_ReturnsNotFoundResponse()
        {
            // Act
            var badResponse = await _controller.Delete(0);

            // Assert
            Assert.IsType <NotFoundResult>(badResponse.Result);
        }
        public async Task DeleteGetActionWithId2_ReturnsModelFromService()
        {
            // Arrange

            // Act
            var result = await validController.Delete(entity.Id) as ViewResult;

            // Assert
            Assert.Equal(entity, result.Model);
        }
Beispiel #3
0
        public void Delete_ReturnsNotEmptyView()
        {
            service.Get <CityView>(city.Id).Returns(city);

            Object expected = NotEmptyView(controller, city);
            Object actual   = controller.Delete(city.Id);

            Assert.Same(expected, actual);
        }
        public async Task It_Is_Possible_To_Invoke_The_Controller_Delete()
        {
            var serviceMock = new Mock <ICityService>();

            serviceMock.Setup(s => s.Delete(It.IsAny <Guid>())).ReturnsAsync(false);

            _controller = new CitiesController(serviceMock.Object);
            _controller.ModelState.AddModelError("Id", "Formato inválido.");

            var result = await _controller.Delete(default(Guid));

            Assert.True(result is BadRequestObjectResult);
        }
Beispiel #5
0
        public async Task It_Is_Possible_To_Invoke_The_Controller_Delete()
        {
            var serviceMock = new Mock <ICityService>();

            serviceMock.Setup(s => s.Delete(It.IsAny <Guid>())).ReturnsAsync(true);
            _controller = new CitiesController(serviceMock.Object);

            var result = await _controller.Delete(Guid.NewGuid());

            Assert.True(result is OkObjectResult);

            var resultValue = ((OkObjectResult)result).Value;

            Assert.NotNull(resultValue);
            Assert.True((bool)resultValue);
        }
Beispiel #6
0
        public void DeleteCityTest()
        {
            var controller = new CitiesController();

            Assert.IsType <OkResult>(controller.Delete(4088));
        }