Beispiel #1
0
        public void EscapeTest()
        {
            var s  = Console.ParseColors("\\[\\\\]");
            var s2 = Console.ParseColors(@"C:\Windows\System32\drivers\etc\hosts");

            Assert.Equal("[\\]", s.DeColorize());
            Assert.Equal(@"C:\Windows\System32\drivers\etc\hosts", s2.DeColorize());
        }
Beispiel #2
0
        public void ColorHandlingTest()
        {
            const string s = "This text IS red";

            var res  = Console.ParseColors($"[red]{s}");
            var res2 = Console.ParseColors($"[b:red]{s}");

            Assert.Equal($"{Foreground.Red}{s}", res);
            Assert.Equal($"{Background.Red}{s}", res2);
        }
Beispiel #3
0
        public void WriteToConsoleTest()
        {
            object obj = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Console.WriteLine(obj);

            Console.WriteLine("123");

            Console.WriteLine("[red]123");
            Console.WriteLine("[f00]123");
            Console.WriteLine("[fff000]123");
            Console.WriteLine("[underline][bold][blink][italic][framed]123");
            Console.WriteLine("123");

            var colors = "black blue green purple red white yellow".Split(' ');

            var foreground = colors.Aggregate("", (current, item) => current + $"[{item}]");

            Console.WriteLine(foreground + "test str");

            var background = colors.Aggregate("", (current, item) => current + $"[b:{item}]");

            Console.WriteLine(background + "test str");

            var brightForeground = colors.Aggregate("", (current, item) => current + $"[bright{item}]");

            Console.WriteLine(brightForeground + "test str");

            var brightBackground = colors.Aggregate("", (current, item) => current + $"[b:bright{item}]");

            Console.WriteLine(brightBackground + "test str");

            Console.Write(foreground + "test str");

            Console.WriteLine(foreground + "{0}", "111");

            var list = new List <string>
            {
                "yes?",
                "no!"
            };

            Console.Write(list);

            Console.WriteLine(list);

            Console.ResetColor();
        }
Beispiel #4
0
 public void AssertConsoleThrows()
 {
     Assert.Throws <FormatException>(() => Console.WriteLine("[gggggg][lol]Some text"));
 }
Beispiel #5
0
 public void AssertConsolePrints()
 {
     Console.WriteLine("[ffaa22]Some text.[reset]\nNow I'm default!");
 }