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); }
public void PutToggleValue() { const string toggleName = "toggle2"; const bool toggleValue = true; _commandHandler .Setup(handler => handler .Execute(It.Is <UpdateToggleValue>(c => c.ToggleName.Equals(toggleName) && c.ToggleValue.Equals(toggleValue)))) .Verifiable(); IActionResult result = _controller.Put(toggleName, toggleValue); _commandHandler .Verify(handler => handler .Execute(It.Is <UpdateToggleValue>(c => c.ToggleName.Equals(toggleName) && c.ToggleValue.Equals(toggleValue)))); Assert.IsType <OkResult>(result); var okResult = result as OkResult; Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); }