示例#1
0
        public void TestThatKeyWithIgnoredModifiersMayBeUnbound()
        {
            var anyKey     = ConsoleKey.C;
            var anyKeyChar = 'c';
            var anyOp      = Any.Enum <ConsoleInputOperation>();

            var bindings = new ConsoleKeyBindingSet();

            bindings.BindWithIgnoredModifiers(anyKey, anyOp);
            bindings.BindWithIgnoredModifiers(anyKey, null);

            bindings.TryGetValue(new ConsoleKeyInfo(anyKeyChar, anyKey, false, false, false), out ConsoleInputOperation op)
            .Should().BeFalse();
        }
示例#2
0
        public void TestThatKeyMayBeBoundWithIgnoredModifiers()
        {
            var anyKey     = ConsoleKey.C;
            var anyKeyChar = 'c';
            var anyOp      = Any.Enum <ConsoleInputOperation>();

            var bindings = new ConsoleKeyBindingSet();

            bindings.BindWithIgnoredModifiers(anyKey, anyOp);

            // It's not enumerable.
            bindings.Values.Should().BeEmpty();

            // ...but it's retrievable.
            void ValidateItIsRetrievableWithModifier(ConsoleModifiers mods)
            {
                bindings.TryGetValue(new ConsoleKeyInfo(anyKeyChar, anyKey, false, false, false), out ConsoleInputOperation op)
                .Should().BeTrue();
                op.Should().Be(anyOp);
            }

            ValidateItIsRetrievableWithModifier((ConsoleModifiers)0);

            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Alt);
            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Control);
            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Shift);

            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Alt | ConsoleModifiers.Control);
            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Alt | ConsoleModifiers.Shift);
            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Control | ConsoleModifiers.Shift);

            ValidateItIsRetrievableWithModifier(ConsoleModifiers.Alt | ConsoleModifiers.Control | ConsoleModifiers.Shift);
        }