public void SetUp() { DropCollections(); var category = new Category() { Name = "Test", Priority = 1 }; EntityStore.Save(category); var user = new User("Jef", "*****@*****.**"); EntityStore.Save(user); var post1 = new Post() { PublishDate = DateTimeProvider.Now, Published = true }; post1.AddLink(new Link(new Uri("http://jefclaes.be"), "Jef Claes", category.Id, user.Id)); var post2 = new Post() { Published = false }; post2.AddLink(new Link(new Uri("http://davybrion.com"), "Davy Brion", category.Id, user.Id)); EntityStore.Save(post1); EntityStore.Save(post2); }
public void Setup() { var generalCategory = AddGeneralCategory(); var user = AddUser(); _post = new Post(); _post.Published = false; _link = new Link(new Uri("http://jefclaes.be"), "Jef Claes", generalCategory.Id, user.Id); _post.AddLink(_link); _post.AddLink(new Link(new Uri("http://google.be"), "Google", generalCategory.Id, user.Id)); MongoContext.GetCollection<Post>().Save(_post); }
public void can_create_post_document() { var posts = _mongoContext.Database.GetCollection<Post>("posts"); var post = new Post(); post.AddLink(new Link(new Uri("http://www.google.com"), "Google", ObjectId.GenerateNewId(), ObjectId.GenerateNewId())); post.AddLink(new Link(new Uri("http://www.facebook.com"), "Facebook", ObjectId.GenerateNewId(), ObjectId.GenerateNewId())); posts.Insert(post); var retrievedPost = posts.Find(Query.EQ("Published", false)).ElementAt(0); Assert.AreEqual(post.Id, retrievedPost.Id); Assert.AreEqual(post.Links.ElementAt(0), retrievedPost.Links.ElementAt(0)); Assert.AreEqual(post.Links.ElementAt(1), retrievedPost.Links.ElementAt(1)); retrievedPost.AddLink(new Link(new Uri("http://www.bing.com"), "Bing", ObjectId.GenerateNewId(), ObjectId.GenerateNewId())); posts.Save(retrievedPost); post = posts.Find(Query.EQ("Published", false)).ElementAt(0); Assert.AreEqual(post.Links.ElementAt(2), retrievedPost.Links.ElementAt(2)); }
public void SetUp() { DropCollections(); var generalCategory = AddGeneralCategory(); var user = AddUser(); _firstPost = new Post(); _firstPost.Published = false; _firstLinkAdded = new Link(new Uri("http://jefclaes.be"), "Jef Claes", generalCategory.Id, user.Id); _firstPost.AddLink(_firstLinkAdded); _firstPost.AddLink(new Link(new Uri("http://google.be"), "Google", generalCategory.Id, user.Id)); _firstPost.AddLink(new Link(new Uri("http://dummy.be"), "I hate dummy data", generalCategory.Id, user.Id)); var anotherPost = new Post(); anotherPost.PublishDate = DateTimeProvider.Now.AddDays(-1); anotherPost.Published = true; anotherPost.AddLink(new Link(new Uri("http://www.yahoo.be"), "Yahoo", generalCategory.Id, user.Id)); MongoContext.GetCollection<Post>().Save(_firstPost); MongoContext.GetCollection<Post>().Save(anotherPost); }
private void SetupPosts() { MongoContext.GetCollection<Post>().Drop(); _publishedPost = new Post(); _publishedPost.PublishDate = _date; _publishedPost.Published = true; _publishedPost.AddLink(new Link(new Uri("http://jclaes.blogspot.com/1"), "Jef Claes link 1", _dotNetCategory.Id, _user.Id)); _publishedPost.AddLink(new Link(new Uri("http://jclaes.blogspot.com/2"), "Jef Claes link 2", _dotNetCategory.Id, _user.Id)); _publishedPost.AddLink(new Link(new Uri("http://jclaes.blogspot.com/3"), "Jef Claes link 3", _dotNetCategory.Id, _user.Id)); _publishedPost.AddLink(new Link(new Uri("http://davybrion.com/1"), "Davy Brion link 1", _nodeCategory.Id, _user.Id)); _unpublishedPost = new Post(); _unpublishedPost.PublishDate = _date.AddDays(7); _unpublishedPost.Published = false; _unpublishedPost.AddLink(new Link(new Uri("http://jefclaes.be/4"), "Jef Claes link 4", _dotNetCategory.Id, _user.Id)); _unpublishedPost.AddLink(new Link(new Uri("http://davybrion.com/2"), "Davy Brion link 2", _nodeCategory.Id, _user.Id)); EntityStore.Save<Post>(_publishedPost); EntityStore.Save<Post>(_unpublishedPost); }