Exemplo n.º 1
0
        public async void ByName_Not_Exists()
        {
            var mock = new ServiceMockFacade <IBucketService, IBucketRepository>();

            mock.RepositoryMock.Setup(x => x.ByName(It.IsAny <string>())).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.ByName("test_value");

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.ByName(It.IsAny <string>()));
        }
Exemplo n.º 2
0
        public async void ByName_Exists()
        {
            var mock   = new ServiceMockFacade <IBucketRepository>();
            var record = new Bucket();

            mock.RepositoryMock.Setup(x => x.ByName(It.IsAny <string>())).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.ByName(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.ByName(It.IsAny <string>()));
        }