Ejemplo n.º 1
0
        public void TestGetSortedListOfPosts(PostComponent postComp)
        {
            var mockPostRepo   = new MockPostRepo();
            var postDataAccess = new PostDataAccess(mockPostRepo, new MockPostValidator(), new MockAuthorRepo(), new MockAuthorValidator());
            var aPost          = new Post("AAA", new Author("AAA", 0), "AAA", Convert.ToDateTime("1111-01-01T11:11:11.1111111Z"), Guid.Parse("11111111-1111-1111-1111-111111111111"));
            var bPost          = new Post("BBB", new Author("BBB", 1), "BBB", Convert.ToDateTime("1112-02-02T12:22:22.2222222Z"), Guid.Parse("22222222-2222-2222-2222-222222222222"));
            var cPost          = new Post("CCC", new Author("CCC", 2), "CCC", Convert.ToDateTime("1113-03-03T13:33:33.3333333Z"), Guid.Parse("33333333-3333-3333-3333-333333333333"));
            var listOfPosts    = new List <Post>()
            {
                cPost, aPost, bPost
            };

            mockPostRepo.StubGetAllPosts(listOfPosts);
            var returnedListOfPosts = postDataAccess.GetSortedListOfPosts(postComp);

            mockPostRepo.AssertGetAllPostsCalled();
            Assert.Equal(listOfPosts.Count, returnedListOfPosts.Count);
            AssertPostsEqual(aPost, returnedListOfPosts[0]);
            AssertPostsEqual(bPost, returnedListOfPosts[1]);
            AssertPostsEqual(cPost, returnedListOfPosts[2]);
        }