Пример #1
0
        public async Task ShouldUpdateValidationValid()
        {
            var solutionSummaryUpdateViewModel = new UpdateSolutionSummaryViewModel {
                Summary = "Summary"
            };
            var validationModel = new Mock <ISimpleResult>();

            validationModel.Setup(s => s.IsValid).Returns(true);

            mockMediator.Setup(m => m.Send(
                                   It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.Data == solutionSummaryUpdateViewModel),
                                   It.IsAny <CancellationToken>()))
            .ReturnsAsync(validationModel.Object);

            var result = await solutionDescriptionController.UpdateAsync(
                SolutionId,
                solutionSummaryUpdateViewModel) as NoContentResult;

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

            mockMediator.Verify(m => m.Send(
                                    It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.Data == solutionSummaryUpdateViewModel),
                                    It.IsAny <CancellationToken>()));
        }
        public async Task ShouldUpdateValidationValid()
        {
            var solutionSummaryUpdateViewModel = new UpdateSolutionSummaryViewModel {
                Summary = "Summary"
            };
            var validationModel = new RequiredMaxLengthResult();

            _mockMediator.Setup(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>())).ReturnsAsync(validationModel);

            var result =
                (await _solutionDescriptionController.UpdateAsync(SolutionId, solutionSummaryUpdateViewModel).ConfigureAwait(false)) as
                NoContentResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            _mockMediator.Verify(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>()), Times.Once);
        }