Beispiel #1
0
        public async void Update()
        {
            var mock  = new ServiceMockFacade <IHandlerPipelineStepRepository>();
            var model = new ApiHandlerPipelineStepRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <HandlerPipelineStep>())).Returns(Task.FromResult(new HandlerPipelineStep()));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new HandlerPipelineStep()));
            var service = new HandlerPipelineStepService(mock.LoggerMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.HandlerPipelineStepModelValidatorMock.Object,
                                                         mock.BOLMapperMockFactory.BOLHandlerPipelineStepMapperMock,
                                                         mock.DALMapperMockFactory.DALHandlerPipelineStepMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.HandlerPipelineStepModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiHandlerPipelineStepRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Update(It.IsAny <HandlerPipelineStep>()));
        }
Beispiel #2
0
        public async void Update_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IHandlerPipelineStepService, IHandlerPipelineStepRepository>();
            var model         = new ApiHandlerPipelineStepServerRequestModel();
            var validatorMock = new Mock <IApiHandlerPipelineStepServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiHandlerPipelineStepServerRequestModel>())).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 HandlerPipelineStep()));
            var service = new HandlerPipelineStepService(mock.LoggerMock.Object,
                                                         mock.MediatorMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         validatorMock.Object,
                                                         mock.DALMapperMockFactory.DALHandlerPipelineStepMapperMock);

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

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