Пример #1
0
        public void Pressed_emits_when_multiple_keys_are_pressed()
        {
            var recognizer = new PlatformKeyListenerStub(new object());
            var newKeys    = default(Key[]);

            recognizer.Pressed.Skip(2).Take(1).Subscribe(keys => newKeys = keys);

            recognizer.OnKeyDown(Key.A);
            recognizer.OnKeyDown(Key.B);
            recognizer.OnKeyDown(Key.C);
            newKeys[0].Should().Be(Key.A, $"because {Key.A} was pressed");
            newKeys[1].Should().Be(Key.B, $"because {Key.B} was pressed");
            newKeys[2].Should().Be(Key.C, $"because {Key.C} was pressed");
        }
Пример #2
0
        public void KeySequenceInProgress_is_true_when_KeyDown_occurs()
        {
            var recognizer = new PlatformKeyListenerStub(new object());

            recognizer.OnKeyDown(Key.A);
            recognizer.KeySequenceInProgress.Should().BeTrue("since key sequence in progress");
        }
Пример #3
0
        public void KeySequenceInProgress_is_false_when_KeyDown_and_KeyUp_occurs()
        {
            var recognizer = new PlatformKeyListenerStub(new object());

            recognizer.OnKeyDown(Key.A);
            recognizer.OnKeyUp(Key.A);
            recognizer.KeySequenceInProgress.Should().BeFalse("since key sequence has ended");
        }
Пример #4
0
        public void KeyDown_emits_when_method_invoked()
        {
            var recognizer = new PlatformKeyListenerStub(new object());
            var keyDown    = false;

            recognizer.KeyDown.Take(1).Subscribe(_ => keyDown = true);

            recognizer.OnKeyDown(Key.A);
            keyDown.Should().BeTrue("because a key-down occurred");
        }
Пример #5
0
        public void Pressed_emits_when_a_key_is_pressed()
        {
            var recognizer = new PlatformKeyListenerStub(new object());
            var newKey     = default(Key?);

            recognizer.Pressed.Take(1).Subscribe(keys => newKey = keys.First());

            recognizer.OnKeyDown(Key.A);
            newKey.Should().Be(Key.A, $"because {Key.A} was pressed");
        }