Exemplo n.º 1
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IPostLinksRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <PostLinks>(null));
            var service = new PostLinksService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.PostLinksModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLPostLinksMapperMock,
                                               mock.DALMapperMockFactory.DALPostLinksMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemplo n.º 2
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IPostLinksRepository>();
            var model = new ApiPostLinksRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <PostLinks>())).Returns(Task.FromResult(new PostLinks()));
            var service = new PostLinksService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.PostLinksModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLPostLinksMapperMock,
                                               mock.DALMapperMockFactory.DALPostLinksMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.PostLinksModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiPostLinksRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <PostLinks>()));
        }
Exemplo n.º 3
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <IPostLinksRepository>();
            var records = new List <PostLinks>();

            records.Add(new PostLinks());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new PostLinksService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.PostLinksModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLPostLinksMapperMock,
                                               mock.DALMapperMockFactory.DALPostLinksMapperMock);

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

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Exemplo n.º 4
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IPostLinksRepository>();
            var model = new ApiPostLinksRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new PostLinksService(mock.LoggerMock.Object,
                                               mock.RepositoryMock.Object,
                                               mock.ModelValidatorMockFactory.PostLinksModelValidatorMock.Object,
                                               mock.BOLMapperMockFactory.BOLPostLinksMapperMock,
                                               mock.DALMapperMockFactory.DALPostLinksMapperMock);

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

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