public void TestGetById_ReturnsNotFoundResultWhenEntityNotFoundException() { Guid toggleId = Guid.NewGuid(); var mockOfITogglesLoader = new MockOfITogglesLoader(new List <Toggle>()); mockOfITogglesLoader.SetupToThrowException( new EntityNotFoundException(typeof(Toggle), toggleId.ToString())); var togglesController = new TogglesController(mockOfITogglesLoader.Object, null, null, null, null); IActionResult result = togglesController.GetById(toggleId); Assert.IsInstanceOf <NotFoundObjectResult>(result); }
public void TestGetById_ReturnsBadRequestResultWhenEntityValidationException() { Guid toggleId = Guid.NewGuid(); var mockOfITogglesLoader = new MockOfITogglesLoader(new List <Toggle>()); mockOfITogglesLoader.SetupToThrowException( new EntityValidationException("")); var togglesController = new TogglesController(mockOfITogglesLoader.Object, null, null, null, null); IActionResult result = togglesController.GetById(toggleId); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public void TestGetById() { var toggle = new Toggle(); var mockOfITogglesLoader = new MockOfITogglesLoader( new List <Toggle>() { toggle }); var togglesController = new TogglesController(mockOfITogglesLoader.Object, null, null, null, null); IActionResult result = togglesController.GetById(toggle.Id); Assert.IsInstanceOf <OkObjectResult>(result); }