Пример #1
0
        public void TestPress1()
        {
            var keyboard = new TestKeyboard();

            foreach (var key in Keys)
            {
                Keyboard.IsKeyDown(key).Should().BeFalse();
                Keyboard.IsKeyUp(key).Should().BeTrue();
                Keyboard.IsKeyToggled(key).Should().BeFalse();
            }

            keyboard.Press(Key.LeftShift);

            foreach (var key in Keys)
            {
                if (key == Key.LeftShift)
                {
                    Keyboard.IsKeyDown(key).Should().BeTrue();
                    Keyboard.IsKeyUp(key).Should().BeFalse();
                }
                else
                {
                    Keyboard.IsKeyDown(key).Should().BeFalse();
                    Keyboard.IsKeyUp(key).Should().BeTrue();
                }
                Keyboard.IsKeyToggled(key).Should().BeFalse();
            }
        }
        public void Setup()
        {
            _control = new SuggestionInputControl
            {
                Style = _style
            };
            _control.ApplyTemplate().Should().BeTrue();
            _control.Popup.Should().NotBeNull();

            _keyboard = new TestKeyboard();
        }
Пример #3
0
        public void TestIsKeyUp1()
        {
            Keyboard.IsKeyUp(Key.LeftShift).Should().BeTrue();

            var keyboard = new TestKeyboard();

            keyboard.Press(Key.LeftShift);
            Keyboard.IsKeyUp(Key.LeftShift).Should().BeFalse();
            keyboard.Release(Key.LeftShift);
            Keyboard.IsKeyUp(Key.LeftShift).Should().BeTrue();
        }
Пример #4
0
        public void TestClickElement1()
        {
            var control = new BrokenControl();

            var keyboard = new TestKeyboard();

            new Action(() => keyboard.Click(control, Key.A)).ShouldThrow <NullReferenceException>("because the control author made a booboo");

            Keyboard.IsKeyDown(Key.A).Should()
            .BeFalse(
                "because TestKeyboard should anticipate client-code failures and reset the state of the A key no matter what");
        }
Пример #5
0
        public void SetUp()
        {
            _mouse    = new TestMouse();
            _keyboard = new TestKeyboard();

            _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default)
            {
                Width  = 800,
                Height = 600
            };
            _control.Arrange(new Rect(0, 0, 800, 600));
            DispatcherExtensions.ExecuteAllEvents();
        }
Пример #6
0
        public void TestKeyboardDeviceIsKeyUp([ValueSource(nameof(Keys))] Key key)
        {
            var device = Keyboard.PrimaryDevice;

            var keyboard = new TestKeyboard();

            device.IsKeyUp(key).Should().BeTrue();

            keyboard.Press(key);
            device.IsKeyUp(key).Should().BeFalse();

            keyboard.Release(key);
            device.IsKeyUp(key).Should().BeTrue();
        }
Пример #7
0
        public void SetUp()
        {
            _mouse    = new TestMouse();
            _keyboard = new TestKeyboard();
            _columns  = Columns.Minimum.Concat(new[] { PageBufferedLogSource.RetrievalState }).ToList();

            _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default)
            {
                Width  = 800,
                Height = 600
            };
            _control.Arrange(new Rect(0, 0, 800, 600));
            _control.ChangeTextSettings(new TextSettings(), new TextBrushes(null));
            DispatcherExtensions.ExecuteAllEvents();
        }
Пример #8
0
        public void TestKeyboardDeviceModifiersControl()
        {
            var device = Keyboard.PrimaryDevice;

            var keyboard = new TestKeyboard();

            device.Modifiers.Should().Be(ModifierKeys.None);

            keyboard.Press(Key.LeftCtrl);
            device.Modifiers.Should().Be(ModifierKeys.Control);

            keyboard.Release(Key.LeftCtrl);
            device.Modifiers.Should().Be(ModifierKeys.None);

            keyboard.Press(Key.RightCtrl);
            device.Modifiers.Should().Be(ModifierKeys.Control);
        }
Пример #9
0
        public void TestInputBinding1([ValueSource(nameof(AllModifierKeys))] ModifierKeys modifierKeys)
        {
            bool pressed = false;

            var control = new FrameworkElement();

            control.InputBindings.Add(new KeyBinding(
                                          new Command(() => pressed = true),
                                          new KeyGesture(Key.B, modifierKeys))
                                      );

            var keyboard = new TestKeyboard();

            keyboard.Click(control, Key.B, modifierKeys);

            pressed.Should().BeTrue("because the control should've interpreted the gesture correctly");
        }
Пример #10
0
        public void SetUp()
        {
            _keyboard = new TestKeyboard();
            _mouse    = new TestMouse();

            _control = new LogEntryListView
            {
                Width  = 1024,
                Height = 768
            };
            var availableSize = new Size(1024, 768);

            _control.Measure(availableSize);
            _control.Arrange(new Rect(new Point(), availableSize));
            DispatcherExtensions.ExecuteAllEvents();


            _logSource = new InMemoryLogSource(Columns.Minimum.Concat(new[] { PageBufferedLogSource.RetrievalState }));

            _deltaTimesColumn = (DeltaTimeColumnPresenter)typeof(LogEntryListView).GetField("_deltaTimesColumn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_control);
        }
Пример #11
0
        public void SetUp()
        {
            _keyboard = new TestKeyboard();
            _mouse    = new TestMouse();

            _control = new LogEntryListView
            {
                Width  = 1024,
                Height = 768
            };
            var availableSize = new Size(1024, 768);

            _control.Measure(availableSize);
            _control.Arrange(new Rect(new Point(), availableSize));
            DispatcherExtensions.ExecuteAllEvents();

            _lines     = new List <LogLine>();
            _listeners = new List <ILogFileListener>();

            _logFile = new Mock <ILogFile>();
            _logFile.Setup(x => x.Count).Returns(() => _lines.Count);
            _logFile.Setup(x => x.GetSection(It.IsAny <LogFileSection>(), It.IsAny <LogLine[]>()))
            .Callback((LogFileSection section, LogLine[] dest) =>
                      _lines.CopyTo((int)section.Index, dest, 0, section.Count));
            _logFile.Setup(x => x.GetLine(It.IsAny <int>())).Returns((int index) =>
                                                                     _lines[index]);
            _logFile.Setup(x => x.AddListener(It.IsAny <ILogFileListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>()))
            .Callback((ILogFileListener listener, TimeSpan maximumTimeout, int maximumLines) =>
            {
                _listeners.Add(listener);
                listener.OnLogFileModified(_logFile.Object,
                                           new LogFileSection(0, _lines.Count));
            });

            _deltaTimesColumn = (DeltaTimeColumnPresenter)typeof(LogEntryListView).GetField("_deltaTimesColumn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_control);
        }
Пример #12
0
 public void OneTimeSetup()
 {
     _keyboard = new TestKeyboard();
 }
Пример #13
0
 public void OneTimeSetUp()
 {
     _mouse    = new TestMouse();
     _keyboard = new TestKeyboard();
 }