public void TestGetPostById_InvalidID_Success() { var nonExistentPostID = "33b9def6-f7db-4120-9f00-6137bbeeb8d1"; var postDataAccess = new PostDataAccess(new MockPostRepo(), new MockPostValidator(), new MockAuthorRepo(), new MockAuthorValidator()); var post = new Post("", new Author("", 0), "", DateTime.Now, Guid.Parse("bb2da75b-3bec-4d92-ba7e-4cbdf7b50759")); var listOfPosts = new List <Post>(); listOfPosts.Add(post); new MockPostRepo().StubGetAllPosts(listOfPosts); var returnedPost = postDataAccess.GetPostById(Guid.Parse(nonExistentPostID)); new MockPostRepo().AssertGetAllPostsCalled(); Assert.Null(returnedPost); }
public void TestGetPostById_ValidID_Success() { var mockPostRepo = new MockPostRepo(); var postDataAccess = new PostDataAccess(mockPostRepo, new MockPostValidator(), new MockAuthorRepo(), new MockAuthorValidator()); var post = new Post("", new Author("", 0), ""); var listOfPosts = new List <Post>() { post }; mockPostRepo.StubGetAllPosts(listOfPosts); var returnedPost = postDataAccess.GetPostById(post.PostID); mockPostRepo.AssertGetAllPostsCalled(); Assert.NotNull(returnedPost); AssertPostsEqual(post, returnedPost); }