public void TestDelete() { var toggle = new Toggle(); var mockOfIDeleteToggleCommand = new MockOfIDeleteToggleCommand(); var togglesController = new TogglesController(null, null, null, null, mockOfIDeleteToggleCommand.Object); IActionResult result = togglesController.Delete(toggle.Id); Assert.IsInstanceOf <NoContentResult>(result); }
public void TestDelete_ReturnsBadRequestResultWhenEntityValidationException() { var toggle = new Toggle(); var mockOfIDeleteToggleCommand = new MockOfIDeleteToggleCommand(); mockOfIDeleteToggleCommand.SetupToThrowException( new EntityValidationException("")); var togglesController = new TogglesController(null, null, null, null, mockOfIDeleteToggleCommand.Object); IActionResult result = togglesController.Delete(toggle.Id); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public void TestDelete_ReturnsNotFoundResultWhenEntityNotFoundException() { var toggle = new Toggle(); var mockOfIDeleteToggleCommand = new MockOfIDeleteToggleCommand(); mockOfIDeleteToggleCommand.SetupToThrowException( new EntityNotFoundException(typeof(Toggle), toggle.Id.ToString())); var togglesController = new TogglesController(null, null, null, null, mockOfIDeleteToggleCommand.Object); IActionResult result = togglesController.Delete(toggle.Id); Assert.IsInstanceOf <NotFoundObjectResult>(result); }
public void DeleteClientInToggle() { _commandHandler .Setup(handler => handler.Execute(It.IsAny <DeleteClientToggle>())) .Verifiable(); IActionResult result = _controller.Delete("toggle1", "client1", "*"); _commandHandler .Verify(handler => handler.Execute(It.IsAny <DeleteClientToggle>())); Assert.IsType <OkResult>(result); var castResult = result as OkResult; Assert.NotNull(castResult); Assert.Equal(200, castResult.StatusCode); }