Пример #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();
        }
Пример #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;
                }
            }
        }
Пример #3
0
        public void DrawClientArea_ChildControlsDrawn()
        {
            var stubbedWindow = new StubbedWindow();

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

            var child1 = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = sut
            };
            var child2 = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = sut
            };

            child1.ResetMethodCount();
            child2.ResetMethodCount();
            sut.DoDrawClientArea(new StubIConsoleGraphics());
            child1.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(1);
            child2.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(1);
        }
Пример #4
0
        public void Controls_ChildAreaChanged_Handled()
        {
            var stubbedWindow = new StubbedWindow();

            var sut = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = stubbedWindow
            };
            var child = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = sut
            };

            sut.ResetMethodCount();
            child.Area = new Rectangle(1, 2, 3, 4);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawClientArea).Should().Be(1);
            sut.Controls.Remove(child);
            sut.ResetMethodCount();
            child.Area = new Rectangle(2, 3, 4, 5);
            sut.GetMethodCount(StubbedConsoleControl.MethodDrawClientArea).Should().Be(0);
        }
Пример #5
0
        public void DrawClientArea_DrawingInhibited_LoggedNotDrawn()
        {
            var stubbedWindow = new StubbedWindow
            {
                DrawingInhibitedGet = () => true
            };

            bool inhibitLogged = false;
            var  sut           = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = stubbedWindow
            };
            var child1 = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = sut
            };
            var child2 = new StubbedConsoleControl(stubbedWindow)
            {
                Parent = sut
            };

            child1.ResetMethodCount();
            child2.ResetMethodCount();
            using var logger = new TestLogger(CheckDrawLog);
            sut.DoDrawClientArea(new StubIConsoleGraphics());
            inhibitLogged.Should().BeTrue();
            child1.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(0);
            child2.GetMethodCount(StubbedConsoleControl.MethodDrawBackground).Should().Be(0);
            void CheckDrawLog(string msg)
            {
                if (msg.Contains("drawing inhibited"))
                {
                    inhibitLogged = true;
                }
            }
        }