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(); }
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(); }