Esempio n. 1
0
        public void Focused_CannotFocus_InvalidOperationException()
        {
            ConControls.Controls.ConsoleControl?focusedControl = null;
            var stubbedWindow = new StubbedWindow
            {
                FocusedControlGet = () => focusedControl,
                FocusedControlSetConsoleControl = ctrl => focusedControl = ctrl
            };
            var sut = new StubbedConsoleControl(stubbedWindow);

            sut.Focused.Should().BeFalse();
            sut.CanFocus.Should().BeFalse();
            bool eventRaised = false;

            sut.FocusedChanged += (sender, e) =>
            {
                sender.Should().Be(sut);
                eventRaised = true;
            };

            sut.GetMethodCount(StubbedConsoleControl.MethodOnFocusedChanged).Should().Be(0);
            eventRaised.Should().BeFalse();
            sut.Invoking(s => s.Focused = true)
            .Should()
            .Throw <InvalidOperationException>();
            sut.Focused.Should().BeFalse();
            sut.GetMethodCount(StubbedConsoleControl.MethodOnFocusedChanged).Should().Be(0);
            eventRaised.Should().BeFalse();
        }
Esempio n. 2
0
        public void CheckDisposed_WindowDisposed_ObjectDisposedException()
        {
            var stubbedWindow = new StubbedWindow();
            var sut           = new StubbedConsoleControl(stubbedWindow);

            stubbedWindow.IsDisposedGet = () => true;
            sut.Invoking(c => c.DoCheckDisposed()).Should().Throw <ObjectDisposedException>().Which.ObjectName.Should().Be(nameof(ConsoleWindow));
        }
Esempio n. 3
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>();
        }
Esempio n. 4
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));
        }
Esempio n. 5
0
        public void Draw_WindowDisposed_ObjectDisposedException()
        {
            var stubbedWindow = new StubbedWindow
            {
                IsDisposedGet = () => true
            };

            var sut = new StubbedConsoleControl(stubbedWindow);

            sut.Invoking(s => s.Draw())
            .Should()
            .Throw <ObjectDisposedException>()
            .Which.ObjectName.Should()
            .Be(nameof(ConsoleWindow));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public void Parent_DifferentWindow_InvalidOperationException()
        {
            var stubbedWindow   = new StubbedWindow();
            var differentWindow = new StubbedWindow();

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

            sut.Invoking(s => s.Parent = differentParent)
            .Should()
            .Throw <InvalidOperationException>();
            sut.GetMethodCount(StubbedConsoleControl.MethodOnParentChanged).Should().Be(1);
            sut.Parent.Should().Be(stubbedWindow);
        }