Example #1
0
        public void DrawBorder_BorderDrawn()
        {
            var stubbedWindow = new StubbedWindow
            {
                BackgroundColorGet = () => ConsoleColor.DarkMagenta,
                BorderColorGet     = () => ConsoleColor.Cyan
            };

            var sut = new StubbedConsoleControl(stubbedWindow)
            {
                Area   = new Rectangle(1, 2, 3, 4),
                Parent = stubbedWindow
            };

            bool borderDrawn = false;
            var  graphics    = new StubIConsoleGraphics
            {
                DrawBorderConsoleColorConsoleColorBorderStyleRectangle = (bg, fg, style, rect) =>
                {
                    fg.Should().Be(ConsoleColor.Cyan);
                    bg.Should().Be(ConsoleColor.DarkMagenta);
                    style.Should().Be(BorderStyle.None);
                    rect.Should().Be(sut.Area);
                    borderDrawn = true;
                }
            };

            sut.DoDrawBorder(graphics);
            borderDrawn.Should().BeTrue();
        }
Example #2
0
        public void DrawBorder_DrawingInhibited_LoggedNotDrawn()
        {
            var stubbedWindow = new StubbedWindow
            {
                DrawingInhibitedGet = () => true,
                BackgroundColorGet  = () => ConsoleColor.DarkMagenta,
                BorderColorGet      = () => ConsoleColor.Cyan
            };

            bool borderDrawn = false;
            var  graphics    = new StubIConsoleGraphics
            {
                DrawBorderConsoleColorConsoleColorBorderStyleRectangle = (bg, fg, style, rect) => borderDrawn = true
            };
            bool inhibitLogged = false;
            var  sut           = new StubbedConsoleControl(stubbedWindow);

            using var logger = new TestLogger(CheckDrawLog);
            sut.DoDrawBorder(graphics);
            inhibitLogged.Should().BeTrue();
            borderDrawn.Should().BeFalse();

            void CheckDrawLog(string msg)
            {
                if (msg.Contains("drawing inhibited"))
                {
                    inhibitLogged = true;
                }
            }
        }