public void TestPost_ReturnsNotFoundResultWhenEntityNotFoundException() { var toggle = new Toggle(); var mockOfICreateToggleCommand = new MockOfICreateToggleCommand(); mockOfICreateToggleCommand.SetupToThrowException( new EntityNotFoundException(typeof(Toggle), toggle.Id.ToString())); var togglesController = new TogglesController(null, null, mockOfICreateToggleCommand.Object, null, null); IActionResult result = togglesController.Post(toggle); Assert.IsInstanceOf <NotFoundObjectResult>(result); }
public void TestPost_ReturnsBadRequestResultWhenEntityValidationException() { var toggle = new Toggle(); var mockOfICreateToggleCommand = new MockOfICreateToggleCommand(); mockOfICreateToggleCommand.SetupToThrowException( new EntityValidationException("")); var togglesController = new TogglesController(null, null, mockOfICreateToggleCommand.Object, null, null); IActionResult result = togglesController.Post(toggle); Assert.IsInstanceOf <BadRequestObjectResult>(result); }