public void TestPut_ReturnsBadRequestResultWhenIdsAreNotEqual() { var toggle = new Toggle(); var mockOfIUpdateToggleCommand = new MockOfIUpdateToggleCommand(); var togglesController = new TogglesController(null, null, null, mockOfIUpdateToggleCommand.Object, null); IActionResult result = togglesController.Put(Guid.NewGuid(), toggle); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public void TestPut() { var toggle = new Toggle(); var mockOfIUpdateToggleCommand = new MockOfIUpdateToggleCommand(); var togglesController = new TogglesController(null, null, null, mockOfIUpdateToggleCommand.Object, null); IActionResult result = togglesController.Put(toggle.Id, toggle); Assert.IsInstanceOf <OkObjectResult>(result); }
public void TestPut_ReturnsBadRequestResultWhenModelStateIsInvalid() { var toggle = new Toggle(); var mockOfIUpdateToggleCommand = new MockOfIUpdateToggleCommand(); var togglesController = new TogglesController(null, null, null, mockOfIUpdateToggleCommand.Object, null); this.ChangeModelStateToBeInvalid(togglesController); IActionResult result = togglesController.Put(toggle.Id, toggle); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public void TestPut_ReturnsBadRequestResultWhenEntityValidationException() { var toggle = new Toggle(); var mockOfIUpdateToggleCommand = new MockOfIUpdateToggleCommand(); mockOfIUpdateToggleCommand.SetupToThrowException( new EntityValidationException("")); var togglesController = new TogglesController(null, null, null, mockOfIUpdateToggleCommand.Object, null); IActionResult result = togglesController.Put(toggle.Id, toggle); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public void TestPut_ReturnsNotFoundResultWhenEntityNotFoundException() { var toggle = new Toggle(); var mockOfIUpdateToggleCommand = new MockOfIUpdateToggleCommand(); mockOfIUpdateToggleCommand.SetupToThrowException( new EntityNotFoundException(typeof(Toggle), toggle.Id.ToString())); var togglesController = new TogglesController(null, null, null, mockOfIUpdateToggleCommand.Object, null); IActionResult result = togglesController.Put(toggle.Id, toggle); Assert.IsInstanceOf <NotFoundObjectResult>(result); }