예제 #1
0
        public void CanResetConfiguration()
        {
            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx.SetLevel(1)));

            HConsole.WriteLine(o, 1, "text1");

            Assert.That(HConsole.Text.ToLf(), Is.EqualTo($"{Prefix()}text1\n".ToLf()));

            HConsole.Reset();

            HConsole.WriteLine(o, 1, "text0");

            Assert.That(HConsole.Text, Is.EqualTo(""));
        }
        public void CanResetConfiguration()
        {
            var capture = new ConsoleCapture();

            var o = new object();

            HConsole.Configure(o, config => config.SetMaxLevel(1));

            using (capture.Output())
            {
                HConsole.WriteLine(o, 1, "text1");
            }

            Assert.That(capture.ReadToEnd().ToLf(), Is.EqualTo($"{Prefix()}text1\n".ToLf()));

            HConsole.Reset();

            using (capture.Output())
            {
                HConsole.WriteLine(o, 1, "text0");
            }

            Assert.That(capture.ReadToEnd(), Is.EqualTo(""));
        }
예제 #3
0
 public void SetUp()
 {
     HConsole.Reset();
 }
예제 #4
0
        public void Configure()
        {
            HConsole.Configure(x => x.Set <object>(xx => xx
                                                   .SetIndent(4)
                                                   .SetPrefix("XX")
                                                   .SetLevel(3)));

            var config = HConsole.Options.Get(new object());

            Assert.That(config.Prefix, Is.EqualTo("XX"));
            Assert.That(config.Indent, Is.EqualTo(4));
            Assert.That(config.Level, Is.EqualTo(3));

            HConsole.Configure(x => x.Set(xx => xx
                                          .SetIndent(33)
                                          .SetPrefix("YY")
                                          .SetLevel(44)));

            config = HConsole.Options.Get(new object());

            Assert.That(config.Prefix, Is.EqualTo("YY"));
            Assert.That(config.Indent, Is.EqualTo(33));
            Assert.That(config.Level, Is.EqualTo(44));

            HConsole.Configure(x => x.Set <object>(xx => xx
                                                   .ClearIndent()
                                                   .ClearPrefix()
                                                   .ClearLevel()));

            config = HConsole.Options.Get(new object());

            Assert.That(config.Prefix, Is.Null);
            Assert.That(config.Indent, Is.EqualTo(0));
            Assert.That(config.Level, Is.EqualTo(-1));

            HConsole.Configure(x => x.Clear <object>());

            var o = new object();

            HConsole.Configure(x => x.Set(o, xx => xx
                                          .SetIndent(4)
                                          .SetPrefix("XX")
                                          .SetLevel(3)));

            config = HConsole.Options.Get(o);

            Assert.That(config.Prefix, Is.EqualTo("XX"));
            Assert.That(config.Indent, Is.EqualTo(4));
            Assert.That(config.Level, Is.EqualTo(3));

            HConsole.Configure(x => x.Clear(o));

            config = HConsole.Options.Get(o);

            Assert.That(config.Prefix, Is.Null);
            Assert.That(config.Indent, Is.EqualTo(0));
            Assert.That(config.Level, Is.EqualTo(-1));

            HConsole.Reset();
            config = HConsole.Options.Get(new object());

            Assert.That(config.Prefix, Is.Null);
            Assert.That(config.Indent, Is.EqualTo(0));
            Assert.That(config.Level, Is.EqualTo(-1));

            HConsole.Configure(x => x.Set(xx => xx.Verbose()));
            config = HConsole.Options.Get(new object());
            Assert.That(config.Level, Is.EqualTo(int.MaxValue));

            HConsole.Configure(x => x.Set(xx => xx.Quiet()));
            config = HConsole.Options.Get(new object());
            Assert.That(config.Level, Is.EqualTo(-1));
        }
예제 #5
0
 public void Reset()
 {
     HConsole.Reset();
 }