示例#1
0
        public void ConsoleControl_CompletelyInitialized_NoParentYet()
        {
            var stubbedWindow = new StubbedWindow
            {
                VisibleGet = () => true
            };

            var sut = new StubbedConsoleControl(stubbedWindow);

            sut.Visible.Should().BeFalse();
            sut.Enabled.Should().BeFalse();
            sut.CanFocus.Should().BeFalse();
            sut.Name.Should().Be(nameof(StubbedConsoleControl));
            sut.Parent.Should().BeNull();

            sut.Parent = stubbedWindow;
            stubbedWindow.KeyEventEvent.Should().NotBeNull();
            stubbedWindow.MouseEventEvent.Should().NotBeNull();
            stubbedWindow.Controls.Should().Contain(sut);

            sut.Dispose();
            stubbedWindow.KeyEventEvent.Should().BeNull();
            stubbedWindow.MouseEventEvent.Should().BeNull();
            sut.Dispose(); // should not throw
        }
示例#2
0
        public void DrawBorder_Disposed_ObjectDisposedException()
        {
            var stubbedWindow = new StubbedWindow();

            var sut = new StubbedConsoleControl(stubbedWindow);

            sut.Dispose();
            sut.Invoking(s => s.DoDrawBorder(new StubIConsoleGraphics()))
            .Should()
            .Throw <ObjectDisposedException>();
        }
示例#3
0
        public void CheckDisposed_ControlDisposed_ObjectDisposedException()
        {
            var stubbedWindow = new StubbedWindow();
            var sut           = new StubbedConsoleControl(stubbedWindow);

            sut.DisposeInternal(false);
            stubbedWindow.KeyEventEvent.Should().NotBeNull();
            stubbedWindow.MouseEventEvent.Should().NotBeNull();
            sut.Dispose();
            sut.Invoking(c => c.DoCheckDisposed())
            .Should().Throw <ObjectDisposedException>()
            .Which
            .ObjectName
            .Should().Be(nameof(StubbedConsoleControl));
        }
示例#4
0
        public void Draw_ControlDisposed_ObjectDisposedException()
        {
            var          stubbedWindow = new StubbedWindow();
            const string name          = "testname";
            var          sut           = new StubbedConsoleControl(stubbedWindow)
            {
                Name = name,
                Area = new Rectangle(1, 1, 10, 10)
            };

            sut.Dispose();
            sut.Invoking(s => s.Draw())
            .Should()
            .Throw <ObjectDisposedException>()
            .Which.ObjectName.Should()
            .Be(name);
        }