public void CreateFromString() { var title = "Some Title"; var slug = "Some-Slug"; var publishDate = System.DateTime.UtcNow; var theString = $@"--- title: {title} slug: {slug} publish-date: {publishDate:O} ... "; var articleMetadata = ArticleMetadata.ReadFrom(theString); Assert.AreEqual(title, articleMetadata.Title); Assert.AreEqual(slug, articleMetadata.Slug); Assert.AreEqual(publishDate, articleMetadata.PublishDate); }
public void ReadFromStream() { var title = "Some Title"; var slug = "Some-Slug"; var publishDate = System.DateTime.UtcNow; var streamString = $@"--- title: {title} slug: {slug} publish-date: {publishDate:O} ... "; var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(streamString)); var articleMetadata = ArticleMetadata.ReadFrom(memoryStream); Assert.AreEqual(title, articleMetadata.Title); Assert.AreEqual(slug, articleMetadata.Slug); Assert.AreEqual(publishDate, articleMetadata.PublishDate); Assert.AreEqual(string.Empty, articleMetadata.Description); }