public void FetchedCollectionWorks() {
            var cloner = new FetchCloner(new TestConfiguration());
            var query = new SelectQuery<Blog>(new NonExecutingSelectQueryExecutor()).Fetch(p => p.Posts) as SelectQuery<Blog>;
            var blog = new Blog {
                                    BlogId = 1,
                                    Posts = new List<Post> { new Post { PostId = 2, Title = "Foo" }, new Post { PostId = 3, Title = "Boo" } }
                                };
            var clone = cloner.Clone(query, blog);

            Assert.False(ReferenceEquals(blog, clone));
            Assert.False(ReferenceEquals(blog.Posts, clone.Posts));
            Assert.False(ReferenceEquals(blog.Posts[0], clone.Posts[0]));
            Assert.False(ReferenceEquals(blog.Posts[1], clone.Posts[1]));
            Assert.Equal("Foo", clone.Posts[0].Title);
            Assert.Equal("Boo", clone.Posts[1].Title);
        }
        public void FetchedCollectionThenFetchWorks() {
            var cloner = new FetchCloner(new TestConfiguration());
            var query =
                new SelectQuery<Blog>(new NonExecutingSelectQueryExecutor()).FetchMany(p => p.Posts).ThenFetch(p => p.Author) as SelectQuery<Blog>;
            var blog = new Blog {
                                    BlogId = 1,
                                    Posts =
                                        new List<Post> {
                                                           new Post { PostId = 2, Title = "Foo", Author = new User { UserId = 5, Username = "******" } },
                                                           new Post { PostId = 3, Title = "Boo", Author = new User { UserId = 7, Username = "******" } }
                                                       }
                                };
            var clone = cloner.Clone(query, blog);

            Assert.False(ReferenceEquals(blog, clone));
            Assert.False(ReferenceEquals(blog.Posts, clone.Posts));
            Assert.False(ReferenceEquals(blog.Posts[0], clone.Posts[0]));
            Assert.False(ReferenceEquals(blog.Posts[1], clone.Posts[1]));
            Assert.False(ReferenceEquals(blog.Posts[0].Author, clone.Posts[0].Author));
            Assert.False(ReferenceEquals(blog.Posts[1].Author, clone.Posts[1].Author));
            Assert.Equal("Foo", clone.Posts[0].Title);
            Assert.Equal("Boo", clone.Posts[1].Title);
            Assert.Equal("james", clone.Posts[0].Author.Username);
            Assert.Equal("mark", clone.Posts[1].Author.Username);
        }
 public void WhereOpequalityWorks() {
     var session = this.GetSession();
     var blog = new Blog { BlogId = 1 };
     var postWithBlog1 = session.Query<Post>().FirstOrDefault(p => p.Blog == blog);
     Assert.NotNull(postWithBlog1);
 }