public void  When_formatting_null_values_then_empty_span_is_returned()
        {
            var formatter = new SpanFormatter();

            var span = formatter.Format(null);

            span.Should().Be(Span.Empty());
        }
            public DirectoryView(DirectoryInfo directory)
            {
                if (directory == null)
                {
                    throw new ArgumentNullException(nameof(directory));
                }

                var formatter = new SpanFormatter();

                formatter.AddFormatter <DateTime>(d => $"{d:d} {ForegroundColorSpan.DarkGray()}{d:t}");

                Add(new ContentView(""));
                Add(new ContentView(""));

                Add(new ContentView($"Directory: {directory.FullName}"));

                Add(new ContentView(""));
                Add(new ContentView(""));

                var directoryContents = directory.EnumerateFileSystemInfos()
                                        .OrderBy(f => f is DirectoryInfo
                                                                   ? 0
                                                                   : 1).ToList();

                var tableView = new TableView <FileSystemInfo>();

                tableView.Items = directoryContents;
                tableView.AddColumn(f => f is DirectoryInfo
                                     ? Span($"{ForegroundColorSpan.LightGreen()}{f.Name} ")
                                     : Span($"{ForegroundColorSpan.White()}{f.Name} "),
                                    new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Name{Ansi.Text.UnderlinedOff}")));

                tableView.AddColumn(f => formatter.Format(f.CreationTime),
                                    new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Created{Ansi.Text.UnderlinedOff}")));
                tableView.AddColumn(f => formatter.Format(f.LastWriteTime),
                                    new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Modified{Ansi.Text.UnderlinedOff}")));

                Add(tableView);

                Span Span(FormattableString formattableString)
                {
                    return(formatter.ParseToSpan(formattableString));
                }
            }
Exemplo n.º 3
0
        public void InlineImgWithoutTitleWithSpecialAttributes()
        {
            var m = GetSetupMarkdown();

            m.ExtraMode = true;
            var s = new SpanFormatter(m);

            Assert.AreEqual("pre <img src=\"url.com/image.png\" alt=\"alt text\" id=\"foo\" class=\"a b cl\" lang=\"nl\" /> post",
                            s.Format("pre ![alt text](url.com/image.png){#foo .a .b .cl lang=nl} post"));
        }
Exemplo n.º 4
0
        public void combined_18()
        {
            var fExtra = new SpanFormatter(new Markdown()
            {
                ExtraMode = true
            });

            Assert.AreEqual("<em>Emphasis</em>, trailing",
                            fExtra.Format("_Emphasis_, trailing"));
        }
Exemplo n.º 5
0
        public void InlineLinkWithoutTitleWithSpecialAttributes()
        {
            var m = GetSetupMarkdown();

            m.ExtraMode = true;
            var s = new SpanFormatter(m);

            Assert.AreEqual("pre <a href=\"url.com\" id=\"foo\" class=\"a b cl\" lang=\"nl\">link text</a> post",
                            s.Format("pre [link text](url.com){#foo .a .b .cl lang=nl} post"));
        }
Exemplo n.º 6
0
        public void combined_17()
        {
            var fExtra = new SpanFormatter(new Markdown()
            {
                ExtraMode = true
            });

            Assert.AreEqual("<strong>Bold</strong> <em>Italic</em>",
                            fExtra.Format("__Bold__ _Italic_"));
        }
Exemplo n.º 7
0
 private static ContentView CreateView(object value, SpanFormatter formatter)
 => new ContentView(formatter.Format(value));
Exemplo n.º 8
0
 public void ReferenceLinkWithTitle()
 {
     Assert.AreEqual("pre <a href=\"url.com\" title=\"title\">link text</a> post",
                     _formatter.Format("pre [link text][link1] post"));
 }
Exemplo n.º 9
0
 public void PlainText()
 {
     Assert.AreEqual("This is plain text",
                     f.Format("This is plain text"));
 }
Exemplo n.º 10
0
 public void SimpleTag()
 {
     Assert.AreEqual(f.Format("pre <a> post"), "pre <a> post");
 }
Exemplo n.º 11
0
 public void AllEscapeCharacters()
 {
     Assert.AreEqual(@"pre \ ` * _ { } [ ] ( ) # + - . ! post",
                     f.Format(@"pre \\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \! post"));
 }
Exemplo n.º 12
0
 public void SingleTick()
 {
     Assert.AreEqual("pre <code>code span</code> post",
                     f.Format("pre `code span` post"));
 }