Exemplo n.º 1
0
        public void TestConstruction()
        {
            var settings = new LogViewerSettings();

            settings.LinesScrolledPerWheelTick.Should().Be(2);
            settings.FontSize.Should().Be(12);
            settings.TabWidth.Should().Be(4);

            settings.Other.ForegroundColor.Should().Be(Colors.Black);
            settings.Other.BackgroundColor.Should().Be(Colors.Transparent);

            settings.Trace.ForegroundColor.Should().Be(Color.FromRgb(128, 128, 128));
            settings.Trace.BackgroundColor.Should().Be(Colors.Transparent);

            settings.Debug.ForegroundColor.Should().Be(Color.FromRgb(128, 128, 128));
            settings.Debug.BackgroundColor.Should().Be(Colors.Transparent);

            settings.Info.ForegroundColor.Should().Be(Colors.Black);
            settings.Info.BackgroundColor.Should().Be(Colors.Transparent);

            settings.Warning.ForegroundColor.Should().Be(Colors.White);
            settings.Warning.BackgroundColor.Should().Be(Color.FromRgb(255, 195, 0));

            settings.Error.ForegroundColor.Should().Be(Colors.White);
            settings.Error.BackgroundColor.Should().Be(Color.FromRgb(232, 17, 35));

            settings.Fatal.ForegroundColor.Should().Be(Colors.White);
            settings.Fatal.BackgroundColor.Should().Be(Color.FromRgb(232, 17, 35));
        }
Exemplo n.º 2
0
        public void TestChangeSettings()
        {
            var settings = new LogViewerSettings();

            _control.Settings = settings;
            _control.PART_ListView.Settings.Should().BeSameAs(settings);
        }
Exemplo n.º 3
0
        public void TestConstruction()
        {
            var settings = new LogViewerSettings();

            settings.LinesScrolledPerWheelTick.Should().Be(2);
            settings.FontSize.Should().Be(12);
        }
Exemplo n.º 4
0
        public void TestChangeSettingsToNull()
        {
            var settings = new LogViewerSettings();

            _control.Settings = settings;
            new Action(() => _control.Settings = null).Should().NotThrow();
            _control.Settings.Should().BeNull();
        }
Exemplo n.º 5
0
        public void TestClone([Values(1, 2, 3, 4)] int linesScrolledPerWheelTick)
        {
            var settings = new LogViewerSettings
            {
                LinesScrolledPerWheelTick = linesScrolledPerWheelTick
            };

            var actualSettings = settings.Clone();

            actualSettings.LinesScrolledPerWheelTick.Should().Be(linesScrolledPerWheelTick);
        }
Exemplo n.º 6
0
        public void TestRoundtrip([Values(1, 2, 5)] int linesScrolledPerWheelTick)
        {
            var settings = new LogViewerSettings
            {
                LinesScrolledPerWheelTick = linesScrolledPerWheelTick
            };

            var          actualSettings = Restore(Save(settings));
            const string reason         = "because all values should roundtrip perfectly";

            actualSettings.LinesScrolledPerWheelTick.Should().Be(linesScrolledPerWheelTick, reason);
        }
Exemplo n.º 7
0
        private static LogViewerSettings Restore(string file)
        {
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(file)))
            {
                using (var reader = XmlReader.Create(stream))
                {
                    reader.MoveToContent();

                    var settings = new LogViewerSettings();
                    settings.Restore(reader);
                    return(settings);
                }
            }
        }
Exemplo n.º 8
0
        private static string Save(LogViewerSettings logViewerSettings)
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("Test");
                    logViewerSettings.Save(writer);
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }

                return(Encoding.UTF8.GetString(stream.ToArray()));
            }
        }
Exemplo n.º 9
0
        public void TestRoundtrip([Values(1, 2)] int linesScrolledPerWheelTick,
                                  [Values(1, 20)] int fontSize,
                                  [Values(1, 2)] int tabWidth)
        {
            var settings = new LogViewerSettings
            {
                LinesScrolledPerWheelTick = linesScrolledPerWheelTick,
                FontSize = fontSize,
                TabWidth = tabWidth,
                Other    = { BackgroundColor = Colors.Red, ForegroundColor = Colors.Firebrick },
                Trace    = { BackgroundColor = Colors.Magenta, ForegroundColor = Colors.Teal },
                Debug    = { BackgroundColor = Colors.Aqua, ForegroundColor = Colors.DodgerBlue },
                Info     = { BackgroundColor = Colors.DarkOrange, ForegroundColor = Colors.AliceBlue },
                Warning  = { BackgroundColor = Colors.Aquamarine, ForegroundColor = Colors.BlanchedAlmond },
                Error    = { BackgroundColor = Colors.BlueViolet, ForegroundColor = Colors.CadetBlue },
                Fatal    = { BackgroundColor = Colors.Coral, ForegroundColor = Colors.HotPink }
            };

            var          actualSettings = Restore(Save(settings));
            const string reason         = "because all values should roundtrip perfectly";

            actualSettings.LinesScrolledPerWheelTick.Should().Be(linesScrolledPerWheelTick, reason);
            actualSettings.FontSize.Should().Be(fontSize, reason);
            actualSettings.TabWidth.Should().Be(tabWidth);
            actualSettings.Other.BackgroundColor.Should().Be(Colors.Red);
            actualSettings.Other.ForegroundColor.Should().Be(Colors.Firebrick);
            actualSettings.Trace.BackgroundColor.Should().Be(Colors.Magenta);
            actualSettings.Trace.ForegroundColor.Should().Be(Colors.Teal);
            actualSettings.Debug.BackgroundColor.Should().Be(Colors.Aqua);
            actualSettings.Debug.ForegroundColor.Should().Be(Colors.DodgerBlue);
            actualSettings.Info.BackgroundColor.Should().Be(Colors.DarkOrange);
            actualSettings.Info.ForegroundColor.Should().Be(Colors.AliceBlue);
            actualSettings.Warning.BackgroundColor.Should().Be(Colors.Aquamarine);
            actualSettings.Warning.ForegroundColor.Should().Be(Colors.BlanchedAlmond);
            actualSettings.Error.BackgroundColor.Should().Be(Colors.BlueViolet);
            actualSettings.Error.ForegroundColor.Should().Be(Colors.CadetBlue);
            actualSettings.Fatal.BackgroundColor.Should().Be(Colors.Coral);
            actualSettings.Fatal.ForegroundColor.Should().Be(Colors.HotPink);
        }