public GetDefinitionSpecs() { _fixture = new Fixture(); _readModelFacade = Substitute.For <IReadModelFacade>(); _controller = new TogglesController(_readModelFacade); _projectId = _fixture.Create <Guid>(); }
public void TestGetAll() { var mockOfITogglesLoader = new MockOfITogglesLoader(new List <Toggle>()); var togglesController = new TogglesController(mockOfITogglesLoader.Object, null, null, null, null); IEnumerable <Toggle> result = togglesController.GetAll(); Assert.IsNotNull(result); }
public void TestGetByApplication() { var mockOfIToggleValuesLoader = new MockOfIToggleValuesLoader(new List <ToggleValue>()); var togglesController = new TogglesController(null, mockOfIToggleValuesLoader.Object, null, null, null); IActionResult result = togglesController.GetByApplication("TestApp", "1.0"); Assert.IsInstanceOf <OkObjectResult>(result); }
public CreateToggleTests() { _mediator = Substitute.For <IMediator>(); _controller = new TogglesController(_mediator); _response = new CreateTogglesResponse { Toggle = Toggle.CreateNew(EditorID.Parse("123"), "one", "two").ToView() }; }
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 TestPost() { var toggle = new Toggle(); var mockOfICreateToggleCommand = new MockOfICreateToggleCommand(); var togglesController = new TogglesController(null, null, mockOfICreateToggleCommand.Object, null, null); IActionResult result = togglesController.Post(toggle); Assert.IsInstanceOf <CreatedResult>(result); }
public GetSingleToggleTests() { _mediator = Substitute.For <IMediator>(); _controller = new TogglesController(_mediator); _mediator .Send(Arg.Any <GetToggleRequest>()) .Returns(new GetToggleResponse { Toggle = new ToggleView() }); }
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 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 CreateToggleTests() { _response = new CreateTogglesResponse { Toggle = Toggle.CreateNew(EditorID.Parse("123"), "one", "two").ToView() }; _mediator = Substitute.For <IMediator>(); _controller = new TogglesController(_mediator); _controller.Url = Substitute.For <IUrlHelper>(); _controller.Url.Action(Arg.Any <UrlActionContext>()).Returns("/api/toggles/id/" + _response.Toggle.ID); }
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 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 TogglesControllerTest() { _toggle.AddOrUpdateCustomValue(new Client("Id2", "*"), false); _toggle.AddToWhitelist(new[] { new Client("id1", "1.1.1.1") }); _queryHandler = new Mock <IQueryHandler>(); _commandHandler = new Mock <ICommandHandler>(); _logger = new Mock <ILogger <TogglesController> >(); _controller = new TogglesController( new ToggleClientParser(), _queryHandler.Object, _commandHandler.Object, _logger.Object); }
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 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() { 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); }
public GetAllTogglesTests() { _mediator = Substitute.For <IMediator>(); _controller = new TogglesController(_mediator); }