예제 #1
0
        public async Task ReturnsAllPosts()
        {
            // Arrange.
            var expectedPosts = _logicDtoFaker.Generate(2);

            SetupMediatorResponse(expectedPosts);

            // Act.
            var response = await _controller.Get();

            Assert.NotNull(response);

            var posts = response.Value.Posts;

            Assert.NotNull(posts);
            Assert.NotEmpty(posts);

            foreach (var expectedPost in expectedPosts)
            {
                var actualPost = posts.Single(p => p.Id == expectedPost.Id);
                Assert.Equal(expectedPost.Content, actualPost.Content);
                Assert.Equal(expectedPost.Content, actualPost.Content);
            }

            VerifyMediatorCalled();
        }
예제 #2
0
        public async Task ReturnsFoundPost()
        {
            // Arrange.
            var expectedPost = _logicDtoFaker.Generate();

            SetupMediatorResponse(expectedPost);

            // Act.
            var response = await _controller.GetById(expectedPost.Id);

            // Assert.
            Assert.NotNull(response);

            var actualPost = response.Value.Post;

            Assert.NotNull(actualPost);
            Assert.Equal(expectedPost.Id, actualPost.Id);
            Assert.Equal(expectedPost.Content, actualPost.Content);
            Assert.Equal(expectedPost.Content, actualPost.Content);

            VerifyMediatorCalled();
        }