예제 #1
0
        public async Task GetByThread_ReturnsAllPosts_WhenProvidedValidId()
        {
            // Arrange
            var posts = new List <ForumPost>
            {
                new ForumPost {
                    Content = "test", Id = 11, ThreadId = 2
                },
                new ForumPost {
                    Content = "test", Id = 22, ThreadId = 2
                }
            };

            _postsRepositoryMock.Setup(x => x.GetByThread(It.IsAny <int>())).ReturnsAsync(posts);

            // Act
            IReadOnlyCollection <PostDetailsModel> result = await _postsService.GetByThread(2);

            // Assert
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.IsTrue(result.Any(x => x.Id == 11));
            Assert.IsTrue(result.Any(x => x.Id == 22));
        }