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(); }
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(); }
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"); }
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(); }
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(); }
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(); }
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); }
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"); }
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); }
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); }
public void OneTimeSetup() { _keyboard = new TestKeyboard(); }
public void OneTimeSetUp() { _mouse = new TestMouse(); _keyboard = new TestKeyboard(); }