Exemplo n.º 1
0
        public async Task When_fetching_a_single_toggle_by_id()
        {
            var locator  = ToggleLocator.Create(ToggleID.CreateNew());
            var response = (JsonResult)await _controller.Get(locator);

            await _mediator.Received().Send(Arg.Is <GetToggleRequest>(req => req.Locator == locator));

            response.Value.ShouldBeOfType <ToggleView>();
        }
Exemplo n.º 2
0
        public async Task When_getting_all_toggles_and_there_are_none()
        {
            _mediator
            .Send(Arg.Any <GetAllTogglesRequest>())
            .Returns(new GetAllTogglesResponse());

            var response = await _controller.Get() as JsonResult;

            ((IEnumerable <ToggleView>)response.Value).ShouldBeEmpty();
        }
Exemplo n.º 3
0
    public void GetByToggleName()
    {
        const string toggleName = "toggle1";

        _queryHandler
        .Setup(handler => handler
               .Execute(It.Is <FetchToggleByName>(f => f.ToggleName.Equals(toggleName))))
        .Returns(_toggle);

        var result = _controller.Get(toggleName);

        Assert.IsType <OkObjectResult>(result);
        var okResult = result as OkObjectResult;

        Assert.NotNull(okResult);
        Assert.Equal(200, okResult.StatusCode);
        Assert.IsType <Toggle>(okResult.Value);

        var toggle = okResult.Value as Toggle;

        Assert.NotNull(toggle);
        Assert.Equal(toggleName, toggle.Name);
        Assert.True(toggle.DefaultValue);
        Assert.NotNull(toggle.Whitelist);
        Assert.NotEmpty(toggle.Whitelist);
        Assert.NotNull(toggle.CustomValues);
        Assert.NotEmpty(toggle.CustomValues);
    }