예제 #1
0
        public void TestGetAllPosts()
        {
            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 returnedListOfPosts = postDataAccess.GetAllPosts();

            mockPostRepo.AssertGetAllPostsCalled();
            Assert.Equal(listOfPosts.Count, returnedListOfPosts.Count);
            AssertPostsEqual(listOfPosts[0], returnedListOfPosts[0]);
        }