public async void Get_ShouldReturnNullBecauseRecordNotFound() { var mock = new ServiceMockFacade <IBucketService, IBucketRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Bucket>(null)); var service = new BucketService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.BucketModelValidatorMock.Object, mock.DALMapperMockFactory.DALBucketMapperMock, mock.DALMapperMockFactory.DALFileMapperMock); ApiBucketServerResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Get() { var mock = new ServiceMockFacade <IBucketRepository>(); var record = new Bucket(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new BucketService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.BucketModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLBucketMapperMock, mock.DALMapperMockFactory.DALBucketMapperMock, mock.BOLMapperMockFactory.BOLFileMapperMock, mock.DALMapperMockFactory.DALFileMapperMock); ApiBucketResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public IActionResult Get() => _bucketService.Get(Request.Headers["token"]) .Map((x) => AllOk(x)) .Reduce(NotFoundErrorHandler, x => x is NotFoundError) .Reduce(InternalServisErrorHandler);