コード例 #1
0
        public SessionExtensionsTests()
        {
            var config   = new TestConfig();
            var database = new InMemoryDatabase(config);

            this.session = database.BeginSession();
            this.session.Insert(new Post {
                Title = "Foo"
            });
        }
コード例 #2
0
        private ISession GetSession()
        {
            var sessionCreator = new InMemoryDatabase(new TestConfiguration());
            var session        = sessionCreator.BeginSession();

            var authors = new List <User> {
                new User {
                    Username = "******", IsEnabled = true
                }, new User {
                    Username = "******", IsEnabled = true
                }, new User {
                    Username = "******", IsEnabled = false
                }
            };

            session.Insert(authors);

            var blogs = new List <Blog> {
                new Blog {
                    Owner = authors[0], Title = "Bob's Blog"
                }
            };

            session.Insert(blogs);

            var posts = new List <Post> {
                new Post {
                    Author = authors[0], Blog = blogs[0], Title = "My First Post"
                },
                new Post {
                    Author = authors[0], Blog = blogs[0], Title = "My Second Post"
                },
                new Post {
                    Author = authors[1], Title = "A post without a blog!"
                }
            };

            session.Insert(posts);

            var comments = new List <Comment> {
                new Comment {
                    User = authors[1], Post = posts[0], Content = "This is marks comment on the first post"
                },
                new Comment {
                    User    = authors[1],
                    Post    = posts[1],
                    Content = "This is marks comment on the second post"
                },
                new Comment {
                    User    = authors[2],
                    Post    = posts[0],
                    Content = "This is james' comment on the first post"
                },
                new Comment {
                    User    = authors[2],
                    Post    = posts[1],
                    Content = "This is james' comment on the second post"
                },
                new Comment {
                    User = authors[0], Post = posts[0], Content = "This is bob's comment on the first post"
                },
                new Comment {
                    User    = authors[0],
                    Post    = posts[1],
                    Content = "This is bob's comment on the second post"
                },
            };

            session.Insert(comments);
            return(session);
        }