Exemple #1
0
        public void TestGetListOfPostsByAuthorID()
        {
            var mockPostRepo    = new MockPostRepo();
            var postDataAccess  = new PostDataAccess(mockPostRepo, new MockPostValidator(), new MockAuthorRepo(), new MockAuthorValidator());
            var postNotByAuthor = new Post("", new Author("NotAuthor", 1), "");
            var postByAuthor    = new Post("", new Author("Author", 0), "");
            var listOfPosts     = new List <Post>()
            {
                postByAuthor
            };


            mockPostRepo.StubGetAllPostsByAuthor(listOfPosts);

            var returnedListOfPosts = postDataAccess.GetListOfPostsByAuthorID(0);

            mockPostRepo.AssertGetAllPostsByAuthorCalled();
            AssertPostsEqual(postByAuthor, returnedListOfPosts[0]);
        }