Ejemplo n.º 1
0
        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>()));
        }
Ejemplo n.º 2
0
        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>()));
        }
Ejemplo n.º 3
0
 public IActionResult Get() =>
 _bucketService.Get(Request.Headers["token"])
 .Map((x) => AllOk(x))
 .Reduce(NotFoundErrorHandler, x => x is NotFoundError)
 .Reduce(InternalServisErrorHandler);