public void GetPostByCategory_ReturnCorrectPost() { AddTestPostsToDB(); var testPostManager = new PostManager(testDBContext, testAutoMapper); var posts = testPostManager.GetPostsByCategory(TestCategory.Id).ToList(); Assert.AreEqual(1, posts.Count); TestPostDto1.AssertContains(posts); }
public void GetPostsByCategory_ReturnCorrectPosts() { // Arrange var mockManager = new Mock <IPostManager>(); mockManager.Setup(x => x.GetPostsByCategory(It.IsAny <Guid>())) .Returns <Guid>(id => GetTestPostsByCategory(id)); var testPostController = new PostsController(mockManager.Object); // Act var posts = testPostController.GetPostsByCategory(TestCategory.Id).ToList(); //Assert Assert.AreEqual(1, posts.Count); TestPost1.AssertContains(posts); }