Exemplo n.º 1
0
        public void testBlogRepo()
        {
            var data = new List <Blog>
            {
                new Blog {
                    Name = "ABBB"
                },
                new Blog {
                    Name = "ZZZ"
                },
                new Blog {
                    Name = "AAA"
                },
            }.AsQueryable();
            var post = new List <MVC.Models.Post>
            {
                new Post {
                }
            }.AsQueryable();

            MockBlogs.As <IQueryable <Blog> >().Setup(e => e.Provider).Returns(data.Provider);
            MockBlogs.As <IQueryable <Blog> >().Setup(e => e.Expression).Returns(data.Expression);
            MockBlogs.As <IQueryable <Blog> >().Setup(e => e.ElementType).Returns(data.ElementType);
            MockBlogs.As <IQueryable <Blog> >().Setup(e => e.GetEnumerator()).Returns(data.GetEnumerator());
            mockContext.Setup(e => e.Blogs).Returns(MockBlogs.Object);
            BlogRepo blog = new BlogRepo(mockContext.Object);

            Assert.AreEqual(blog.GetBlogsByName(e => e.Name.StartsWith("A")).Count, 2);
        }