Esempio n. 1
0
        private void InsertData(ISession session) {
            var users = new List<User>();
            for (var i = 0; i < 10; i++) {
                var user = new User { Username = "******" + i };
                users.Add(user);
                session.Insert(user);
            }

            var blogs = new List<Blog>();
            for (var i = 0; i < 10; i++) {
                var blog = new Blog { Title = "Blog_" + i };
                blogs.Add(blog);
                session.Insert(blog);
            }

            var posts = new List<Post>();
            for (var i = 0; i < 20; i++) {
                var userId = i / 2;
                var blogId = i / 2;
                var post = new Post { Author = users[userId], Blog = blogs[blogId], Title = "Post_" + i };
                session.Insert(post);
                posts.Add(post);
            }

            for (var i = 0; i < 30; i++) {
                var comment = new Comment { Post = posts[i / 2], User = users[i / 3], Content = "Comment_" + i };
                session.Insert(comment);
            }

            var tags = new List<Tag>();
            for (var i = 0; i < 20; i++) {
                var tag = new Tag { Content = "Tag_" + i };
                tags.Add(tag);
                session.Insert(tag);
            }

            for (var i = 0; i < 30; i++) {
                var postTag = new PostTag { Post = posts[i / 2], Tag = tags[i / 2] };
                session.Insert(postTag);
            }

            // insert single comment with null User to check that nulls are returned properly
            var nullUserComment = new Comment { Post = posts[0], User = null, Content = "Nullable User Content" };
            session.Insert(nullUserComment);

            var nullTag = new Tag { Content = "Null Post Tag" };
            session.Insert(nullTag);
            var nullPostTag = new PostTag { Tag = nullTag };
            session.Insert(nullPostTag);

            // add user for bulk update
            session.Insert(new User { Username = "******", Password = "******" });

            // add users for bulk delete
            session.Insert(new User { Username = "******", Password = "******" }, new User { Username = "******", Password = "******" });

            // test delete user
            session.Insert(new User { Username = "******", Password = "******" });

            // test empty collection
            session.Insert(new Blog { Title = "EmptyBlog" });

            // multiple fetch many stuff
            session.Insert(new Questionnaire { Name = "Foo" });
            session.Insert(new Question { Questionnaire = new Questionnaire { QuestionnaireId = 1 }, Name = "Bar" });
            session.Insert(new Booking());
            session.Insert(new Room { Name = "Room 1" });
            session.Insert(new RoomSlot { Room = new Room { RoomId = 1 } });
            session.Insert(new Bed { RoomSlot = new RoomSlot { RoomSlotId = 1 }, Booking = new Booking { BookingId = 1 } });
            session.Insert(
                new QuestionnaireResponse { Booking = new Booking { BookingId = 1 }, Questionnaire = new Questionnaire { QuestionnaireId = 1 } });
            session.Insert(
                new QuestionResponse {
                                         Question = new Question { QuestionId = 1 },
                                         QuestionnaireResponse = new QuestionnaireResponse { QuestionnaireResponseId = 1 }
                                     });
        }
Esempio n. 2
0
        private void InsertData() {
            var users = new List<User>();
            for (var i = 0; i < 10; i++) {
                var user = new User { Username = "******" + i };
                users.Add(user);
                this.Session.Insert(user);
            }

            var blogs = new List<Blog>();
            for (var i = 0; i < 10; i++) {
                var blog = new Blog { Title = "Blog_" + i };
                blogs.Add(blog);
                this.Session.Insert(blog);
            }

            var posts = new List<Post>();
            for (var i = 0; i < 20; i++) {
                var userId = i / 2;
                var blogId = i / 2;
                var post = new Post { Author = users[userId], Blog = blogs[blogId], Title = "Post_" + i };
                this.Session.Insert(post);
                posts.Add(post);
            }

            for (var i = 0; i < 30; i++) {
                var comment = new Comment { Post = posts[i / 2], User = users[i / 3], Content = "Comment_" + i };
                this.Session.Insert(comment);
            }

            var tags = new List<Tag>();
            for (var i = 0; i < 20; i++) {
                var tag = new Tag { Content = "Tag_" + i };
                tags.Add(tag);
                this.Session.Insert(tag);
            }

            for (var i = 0; i < 30; i++) {
                var postTag = new PostTag { Post = posts[i / 2], Tag = tags[i / 2] };
                this.Session.Insert(postTag);
            }

            // insert single comment with null User to check that nulls are returned properly
            var nullUserComment = new Comment { Post = posts[0], User = null, Content = "Nullable User Content" };
            this.Session.Insert(nullUserComment);

            var nullTag = new Tag { Content = "Null Post Tag" };
            this.Session.Insert(nullTag);
            var nullPostTag = new PostTag { Tag = nullTag };
            this.Session.Insert(nullPostTag);

            // add user for bulk update
            this.Session.Insert(new User { Username = "******", Password = "******" });

            // add users for bulk delete
            this.Session.Insert(new User { Username = "******", Password = "******" }, new User { Username = "******", Password = "******" });

            // test delete user
            this.Session.Insert(new User { Username = "******", Password = "******" });

            // test empty collection
            this.Session.Insert(new Blog { Title = "EmptyBlog" });
        }