Beispiel #1
0
        public void Draw_WithGraphics_AllPartsDrawnNotFlushed()
        {
            bool flushed  = false;
            var  graphics = new StubIConsoleGraphics
            {
                Flush = () => flushed = true
            };
            var stubbedWindow = new StubbedWindow
            {
                GetGraphics = () => graphics
            };
            var sut = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = stubbedWindow
            };

            flushed = false;
            stubbedWindow.GetGraphics = () => null;
            sut.ResetMethodCount();
            sut.Draw(graphics);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(1);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawBorder).Should().Be(1);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawClientArea).Should().Be(1);
            flushed.Should().BeFalse();
        }
Beispiel #2
0
        public void Draw_DrawingInhibited_LoggedNotDrawn()
        {
            var stubbedWindow = new StubbedWindow
            {
                DrawingInhibitedGet = () => true
            };
            bool inhibitLogged = false;
            var  sut           = new StubbedConsoleControl(stubbedWindow);

            using var logger = new TestLogger(CheckDrawLog);
            sut.ResetMethodCount();
            sut.Draw();
            inhibitLogged.Should().BeTrue();
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(0);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawBorder).Should().Be(0);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawClientArea).Should().Be(0);

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