Пример #1
0
        public async Task ShouldUpdateValidationValid()
        {
            var expected  = "an integrations url";
            var viewModel = new UpdateIntegrationsViewModel {
                Url = expected
            };

            var result =
                (await _controller.Update(SolutionId, viewModel).ConfigureAwait(false)) as
                NoContentResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            _mediatorMock.Verify(m => m.Send(It.Is <UpdateIntegrationsCommand>(q => q.SolutionId == SolutionId && q.Url == expected), It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task ShouldUpdateValidationValid()
        {
            const string expected = "an integrations url";
            var          model    = new UpdateIntegrationsViewModel {
                Url = expected
            };

            var result = await controller.Update(SolutionId, model) as NoContentResult;

            Assert.NotNull(result);
            result.StatusCode.Should().Be(StatusCodes.Status204NoContent);

            mediatorMock.Verify(m => m.Send(
                                    It.Is <UpdateIntegrationsCommand>(c => c.SolutionId == SolutionId && c.Url == expected),
                                    It.IsAny <CancellationToken>()));
        }
Пример #3
0
        public async Task ShouldUpdateValidationInvalid()
        {
            var expected  = "an integrations url";
            var viewModel = new UpdateIntegrationsViewModel {
                Url = expected
            };

            _resultDictionary.Add("link", "maxLength");

            var result =
                (await _controller.Update(SolutionId, viewModel).ConfigureAwait(false)) as BadRequestObjectResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            var resultValue = result.Value as Dictionary <string, string>;

            resultValue.Count.Should().Be(1);
            resultValue["link"].Should().Be("maxLength");

            _mediatorMock.Verify(m => m.Send(
                                     It.Is <UpdateIntegrationsCommand>(q => q.SolutionId == SolutionId && q.Url == expected),
                                     It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task ShouldUpdateValidationInvalid()
        {
            const string expected = "an integrations url";
            var          model    = new UpdateIntegrationsViewModel {
                Url = expected
            };

            resultDictionary.Add("link", "maxLength");

            var result = await controller.Update(SolutionId, model) as BadRequestObjectResult;

            Assert.NotNull(result);
            result.StatusCode.Should().Be(StatusCodes.Status400BadRequest);

            var resultValue = result.Value as Dictionary <string, string>;

            Assert.NotNull(resultValue);
            resultValue.Count.Should().Be(1);
            resultValue["link"].Should().Be("maxLength");

            mediatorMock.Verify(m => m.Send(
                                    It.Is <UpdateIntegrationsCommand>(q => q.SolutionId == SolutionId && q.Url == expected),
                                    It.IsAny <CancellationToken>()));
        }
Пример #5
0
 public async Task <ActionResult> Update([FromRoute][Required] string id, [FromBody][Required] UpdateIntegrationsViewModel integrations) =>
 (await _mediator.Send(new UpdateIntegrationsCommand(id, integrations?.Url)).ConfigureAwait(false)).ToActionResult();
Пример #6
0
 public async Task <ActionResult> Update([Required] string id, UpdateIntegrationsViewModel model) =>
 (await mediator.Send(new UpdateIntegrationsCommand(id, model?.Url))).ToActionResult();