public void CanCreateNewBlogPost() { // Act. BlogPost post = BlogPost.Create(new BlogPost { DatePublished = DateTime.Now, Title = "My Blog Post", Text = "Some text" }); // Assert. Assert.That(post.ID, Is.Not.EqualTo(ObjectId.Empty)); }
public void CanDropAllCollections() { // Arrange. BlogPost.Create(new BlogPost { DatePublished = DateTime.Now, Title = "Blog post title", Text = "My blog post" }); Assert.That(OrmongoConfiguration.GetMongoDatabase().CollectionExists("BlogPost"), Is.True); // Act. OrmongoConfiguration.DropAllCollections(); // Assert. Assert.That(OrmongoConfiguration.GetMongoDatabase().CollectionExists("BlogPost"), Is.False); }
public void CanCloseConnection() { // Arrange. BlogPost.Create(new BlogPost { DatePublished = DateTime.Now, Title = "Blog post title", Text = "My blog post" }); Assert.That(OrmongoConfiguration.GetMongoServer().State, Is.EqualTo(MongoServerState.Connected)); // Act. OrmongoConfiguration.CloseConnection(); // Assert. Assert.That(OrmongoConfiguration.GetMongoServer().State, Is.EqualTo(MongoServerState.Disconnected)); }
public void DefaultScope() { // Arrange. var defaultScope = BlogPost.DefaultScope; BlogPost.DefaultScope = items => items.OrderBy(d => d.Title); BlogPost post1 = BlogPost.Create(new BlogPost { Title = "Z", }); BlogPost post2 = BlogPost.Create(new BlogPost { Title = "A", }); // Act. BlogPost retrievedPost = BlogPost.All().First(); // Assert. Assert.That(retrievedPost.ID, Is.EqualTo(post2.ID)); // Clean up. BlogPost.DefaultScope = defaultScope; }