public async void Update()
        {
            var mock  = new ServiceMockFacade <IPipelineStepStatusRepository>();
            var model = new ApiPipelineStepStatusRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <PipelineStepStatus>())).Returns(Task.FromResult(new PipelineStepStatus()));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new PipelineStepStatus()));
            var service = new PipelineStepStatusService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepStatusMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepStatusMapperMock,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepMapperMock);

            UpdateResponse <ApiPipelineStepStatusResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiPipelineStepStatusRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Update(It.IsAny <PipelineStepStatus>()));
        }
Пример #2
0
        public async void Update_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IPipelineStepStatusService, IPipelineStepStatusRepository>();
            var model         = new ApiPipelineStepStatusServerRequestModel();
            var validatorMock = new Mock <IApiPipelineStepStatusServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiPipelineStepStatusServerRequestModel>())).Returns(Task.FromResult(new ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new PipelineStepStatus()));
            var service = new PipelineStepStatusService(mock.LoggerMock.Object,
                                                        mock.MediatorMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        validatorMock.Object,
                                                        mock.DALMapperMockFactory.DALPipelineStepStatusMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepMapperMock);

            UpdateResponse <ApiPipelineStepStatusServerResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiPipelineStepStatusServerRequestModel>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <PipelineStepStatusUpdatedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }