public void Load_tags() { // Arrange var post = new TestablePost(); post.Metadata = new NameValueCollection { {"tags", "life, stuff, more stuff"} }; // Act var tags = post.LoadTags(); // Assert Assert.That(tags, Is.EquivalentTo(new[] { "life", "stuff", "more stuff", })); }
public void Retrieve_post_title_with_many_h1_elements() { // Arrange var post = new TestablePost(); post.Body = @" <h1>This is the title</h1> <h1>This is not the title</h1> <p>This is a paragraph</p>"; // Act post.RetrieveTitle(); // Assert Assert.That(post.Title, Is.EqualTo("This is the title")); Assert.That(post.Body, Is.EqualTo(@" <h1>This is not the title</h1> <p>This is a paragraph</p>")); }
public void Retrieve_post_title_when_h1_has_attributes() { // Arrange var post = new TestablePost(); post.Body = @" <h1 id=""this-is-the-title"">This is the title</h1> <p>This is a paragraph</p>"; // Act post.RetrieveTitle(); // Assert Assert.That(post.Title, Is.EqualTo("This is the title")); Assert.That(post.Body, Is.EqualTo(@" <p>This is a paragraph</p>")); }
public void Extract_metadata() { // Arrange var post = new TestablePost { Body = @"@template some-template @otherValue ok this is the body" }; // Act post.ExtractMetadata(); // Assert Assert.That(post.Metadata.AsDictionary(), Is.EquivalentTo(new Dictionary<string, string> { {"template", "some-template"}, {"otherValue", "ok"} })); Assert.That(post.Body, Is.EqualTo(@"this is the body" + Environment.NewLine)); }
public void Resolve_permalink() { // Arrange var post = new TestablePost { Date = new DateTime(2012, 7, 22), Slug = "my-other-post" }; // Act var permalink = post.ResolvePermalink(":year/:month/:day/:title"); // Assert Assert.That(permalink, Is.EqualTo("/2012/07/22/my-other-post")); }