public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IIllustrationRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Illustration>(null));
            var service = new IllustrationService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALIllustrationMapperMock);

            ApiIllustrationResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Example #2
0
        public async void ProductModelIllustrations_Not_Exists()
        {
            var mock = new ServiceMockFacade <IIllustrationRepository>();

            mock.RepositoryMock.Setup(x => x.ProductModelIllustrations(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <ProductModelIllustration> >(new List <ProductModelIllustration>()));
            var service = new IllustrationService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALIllustrationMapperMock,
                                                  mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock);

            List <ApiProductModelIllustrationResponseModel> response = await service.ProductModelIllustrations(default(int));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.ProductModelIllustrations(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IIllustrationRepository>();
            var model = new ApiIllustrationRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Illustration>())).Returns(Task.FromResult(new Illustration()));
            var service = new IllustrationService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALIllustrationMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiIllustrationRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Illustration>()));
        }
        public async void All()
        {
            var mock    = new ServiceMockFacade <IIllustrationRepository>();
            var records = new List <Illustration>();

            records.Add(new Illustration());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new IllustrationService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALIllustrationMapperMock);

            List <ApiIllustrationResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IIllustrationRepository>();
            var model = new ApiIllustrationRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new IllustrationService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLIllustrationMapperMock,
                                                  mock.DALMapperMockFactory.DALIllustrationMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.IllustrationModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }