Beispiel #1
0
        public void When_Initial_Press_Locks()
        {
            KeyboardStateTracker.OnKeyDown(VirtualKey.B);

            var state = KeyboardStateTracker.GetKeyState(VirtualKey.B);

            Assert.AreEqual(CoreVirtualKeyStates.Down | CoreVirtualKeyStates.Locked, state);
        }
Beispiel #2
0
        public void When_Release_Keeps_Lock()
        {
            KeyboardStateTracker.OnKeyDown(VirtualKey.C);
            KeyboardStateTracker.OnKeyUp(VirtualKey.C);

            var state = KeyboardStateTracker.GetKeyState(VirtualKey.C);

            Assert.AreEqual(CoreVirtualKeyStates.None | CoreVirtualKeyStates.Locked, state);
        }
Beispiel #3
0
        public void When_Second_Down_Unlocks()
        {
            KeyboardStateTracker.OnKeyDown(VirtualKey.D);
            KeyboardStateTracker.OnKeyUp(VirtualKey.D);
            KeyboardStateTracker.OnKeyDown(VirtualKey.D);

            var state = KeyboardStateTracker.GetKeyState(VirtualKey.D);

            Assert.AreEqual(CoreVirtualKeyStates.Down, state);
        }
Beispiel #4
0
        public void When_Second_Release_Keeps_Unlocked()
        {
            KeyboardStateTracker.OnKeyDown(VirtualKey.E);
            KeyboardStateTracker.OnKeyUp(VirtualKey.E);
            KeyboardStateTracker.OnKeyDown(VirtualKey.E);
            KeyboardStateTracker.OnKeyUp(VirtualKey.E);

            var state = KeyboardStateTracker.GetKeyState(VirtualKey.E);

            Assert.AreEqual(CoreVirtualKeyStates.None, state);
        }
Beispiel #5
0
        public void When_Odd_KeyDown()
        {
            for (int i = 0; i < 10; i++)
            {
                // Every odd down should not have lock
                KeyboardStateTracker.OnKeyDown(VirtualKey.G);

                var state = KeyboardStateTracker.GetKeyState(VirtualKey.G);
                Assert.AreEqual(CoreVirtualKeyStates.Down | CoreVirtualKeyStates.Locked, state);

                KeyboardStateTracker.OnKeyUp(VirtualKey.G);

                state = KeyboardStateTracker.GetKeyState(VirtualKey.G);
                Assert.AreEqual(CoreVirtualKeyStates.None | CoreVirtualKeyStates.Locked, state);

                // Unlock sequence
                KeyboardStateTracker.OnKeyDown(VirtualKey.G);
                KeyboardStateTracker.OnKeyUp(VirtualKey.G);
            }
        }
Beispiel #6
0
        public void When_Even_KeyDown()
        {
            for (int i = 0; i < 10; i++)
            {
                // Odd sequence unlocks
                KeyboardStateTracker.OnKeyDown(VirtualKey.F);
                KeyboardStateTracker.OnKeyUp(VirtualKey.F);

                // Every even down should set lock
                KeyboardStateTracker.OnKeyDown(VirtualKey.F);

                var state = KeyboardStateTracker.GetKeyState(VirtualKey.F);
                Assert.AreEqual(CoreVirtualKeyStates.Down, state);

                KeyboardStateTracker.OnKeyUp(VirtualKey.F);

                state = KeyboardStateTracker.GetKeyState(VirtualKey.F);
                Assert.AreEqual(CoreVirtualKeyStates.None, state);
            }
        }