Exemplo n.º 1
0
        public void All_WithExistingPublicationId_ShouldReturnComments()
        {
            // Arrange
            StarStuffDbContext db             = this.Database;
            CommentService     commentService = new CommentService(db);

            this.SeedCommanets(db);
            this.SeedPublication(db);
            this.SeedUser(db);

            List <Comment> fakeComments = this.GetFakeComments()
                                          .Skip(5)
                                          .Take(5)
                                          .ToList();

            int i = -1;

            // Act
            IEnumerable <ListCommentsServiceModel> comments = commentService.All(1, 2, 5, 1);

            // Assert
            foreach (var actual in comments)
            {
                Comment expected = fakeComments[++i];
                expected.DateAdded = expected.DateAdded.ToLocalTime();

                this.CompareComments(expected, actual);
            }
        }
Exemplo n.º 2
0
        public void All_WithNotExistingPublicationId_ShouldReturnEmptyCollection()
        {
            // Arrange
            StarStuffDbContext db             = this.Database;
            CommentService     commentService = new CommentService(db);

            // Act
            IEnumerable <ListCommentsServiceModel> result = commentService.All(1, 2, 5, 1);

            // Assert
            Assert.False(result.Any());
        }
Exemplo n.º 3
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <ICommentRepository>();
            var records = new List <Comment>();

            records.Add(new Comment());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new CommentService(mock.LoggerMock.Object,
                                             mock.RepositoryMock.Object,
                                             mock.ModelValidatorMockFactory.CommentModelValidatorMock.Object,
                                             mock.BOLMapperMockFactory.BOLCommentMapperMock,
                                             mock.DALMapperMockFactory.DALCommentMapperMock);

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

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }