Ejemplo n.º 1
0
        public void DetectJsonTest()
        {
            var input = @"{
       ""categories"": [
      ""Development"",
      ""VIM""
   ],
   ""date"": ""2012-04-06"",
""images"": [""site-feature-image.jpg""],
""testint"": 1,
""testbool"": false,
""title"": ""About""
}
Lorem ipsum";

            var converter    = new StringToStreamConverter(input);
            var typeDetector = new TypeDetector(new StreamReader(converter.GetStreamFromString()));

            using TextReader sr = new StringReader(input);
            var parser = new JsonParser <SinglePage>(sr, string.Empty);
            var single = parser.GetAsSinglePage();

            Assert.Equal(FrontMatterType.Json, typeDetector.GetFrontMatterType());
            Assert.Equal("About", single.Title);
            Assert.Equal("Lorem ipsum", single.Content);
        }
Ejemplo n.º 2
0
        public void DetectMarkdownDocumentTest()
        {
            var input     = "Lorem ipsum";
            var converter = new StringToStreamConverter(input);

            using var sr = new StreamReader(converter.GetStreamFromString());
            var typeDetector = new TypeDetector(sr);

            Assert.Equal(FrontMatterType.MarkdownDocument, typeDetector.GetFrontMatterType());
        }
Ejemplo n.º 3
0
        public void DetectHtmlDocumentTest()
        {
            var input     = @"<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>";
            var converter = new StringToStreamConverter(input);

            using var sr = new StreamReader(converter.GetStreamFromString());
            var typeDetector = new TypeDetector(sr);

            Assert.Equal(FrontMatterType.HtmlDocument, typeDetector.GetFrontMatterType());
        }
Ejemplo n.º 4
0
        public void DetectTomlTest()
        {
            var input = @"
+++
title =  ""About"" 
+++ 
Lorem ipsum";

            var converter    = new StringToStreamConverter(input);
            var typeDetector = new TypeDetector(new StreamReader(converter.GetStreamFromString()));

            using TextReader sr = new StringReader(input);
            var parser = new TomlParser <SinglePage>(sr, string.Empty);
            var single = parser.GetAsSinglePage();

            Assert.Equal(FrontMatterType.Toml, typeDetector.GetFrontMatterType());
            Assert.Equal("About", single.Title);
            Assert.Equal("Lorem ipsum", single.Content);
        }