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

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <PipelineStepStatus>())).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);

            CreateResponse <ApiPipelineStepStatusResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiPipelineStepStatusRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <PipelineStepStatus>()));
        }
Beispiel #2
0
        public async void Create_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock = new ServiceMockFacade <IPipelineStepStatusService, IPipelineStepStatusRepository>();

            var model = new ApiPipelineStepStatusServerRequestModel();

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

            CreateResponse <ApiPipelineStepStatusServerResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiPipelineStepStatusServerRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <PipelineStepStatus>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <PipelineStepStatusCreatedNotification>(), It.IsAny <CancellationToken>()));
        }
Beispiel #3
0
        public async void Create_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IPipelineStepStatusService, IPipelineStepStatusRepository>();
            var model         = new ApiPipelineStepStatusServerRequestModel();
            var validatorMock = new Mock <IApiPipelineStepStatusServerRequestModelValidator>();

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

            CreateResponse <ApiPipelineStepStatusServerResponseModel> response = await service.Create(model);

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