public void keeps_order_of_streams()
        {
            // arrange
            var keySequence = KeyStreams.CtrlU()
                              .Concat(KeyStreams.LetterL())
                              .Concat(KeyStreams.Number1())
                              .Concat(KeyStreams.LetterL())
                              .ToObservable();
            var sut = CreateMessageProvider(keySequence);

            shortcutProvider
            .GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            var messages = sut.GetMessageStream().ToList().Single();

            // assert
            Assert.Equal(3, messages.Count);
            Assert.Equal("Ctrl + U, l [SomeShortcut]", string.Join("", messages[0].Text));
            Assert.Equal("SomeShortcut", messages[0].ShortcutName);
            Assert.Equal("1", string.Join("", messages[1].Text));
            Assert.Equal("1l", string.Join("", messages[2].Text));
        }
Exemplo n.º 2
0
        public async Task verify_shift_number()
        {
            // arrange
            var player   = KeyStreams.ExclaimationMark();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(new[] { "!" }, processedKeys.Single().Input);
        }
Exemplo n.º 3
0
        public void shift_is_not_outputted_when_is_being_used_as_a_modifier_key()
        {
            // arrange
            var player   = KeyStreams.ShiftL();
            var provider = new KeyProvider(player, passwordModeService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "L" }, processedKeys.Single().Input);
        }
Exemplo n.º 4
0
        public void ctrlshiftl_is_processed_correctly()
        {
            // arrange
            var player   = KeyStreams.CtrlShiftL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "Ctrl", "Shift", "L" }, processedKeys.Single().Input);
        }
Exemplo n.º 5
0
        public async Task key_without_shift_is_lowercase()
        {
            // arrange
            var player   = KeyStreams.LetterL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(new[] { "l" }, processedKeys.Single().Input);
        }
Exemplo n.º 6
0
        public void key_without_shift_is_lowercase()
        {
            // arrange
            var player   = KeyStreams.LetterL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "l" }, processedKeys.Single().Input);
        }
Exemplo n.º 7
0
        public async Task ctrlshiftl_is_processed_correctly()
        {
            // arrange
            var player   = KeyStreams.CtrlShiftL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(new[] { "Ctrl", "Shift", "L" }, processedKeys.Single().Input);
        }
Exemplo n.º 8
0
        public async Task keyprovider_detects_windows_key_presses()
        {
            // arrange
            var player   = KeyStreams.WinkeyE();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(new[] { "Win", "e" }, processedKeys.Single().Input);
        }
Exemplo n.º 9
0
        public void verify_shift_number()
        {
            // arrange
            var player   = KeyStreams.ExclaimationMark();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "!" }, processedKeys.Single().Input);
        }
Exemplo n.º 10
0
        public void verify_number()
        {
            // arrange
            var player   = KeyStreams.Number1();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

            // act
            var processedKeys = provider.GetKeyStream().ToList().Single();

            // assert
            Assert.Equal(new[] { "1" }, processedKeys.Single().Input);
        }
Exemplo n.º 11
0
        public void keyprovider_detects_windows_key_presses()
        {
            // arrange
            var player   = KeyStreams.WinkeyE();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "Win", "e" }, processedKeys.Single().Input);
        }
Exemplo n.º 12
0
        public void key_with_modifiers_raises_a_new_message()
        {
            // arrange
            messageProvider.Subscribe(this);
            KeyStreams.LetterL().Play(interceptKeysSource);

            // act
            KeyStreams.CtrlShiftL().Play(interceptKeysSource);

            // assert
            Assert.Equal(2, messages.Count);
        }
Exemplo n.º 13
0
        public void verify_number()
        {
            // arrange
            var player   = KeyStreams.Number1();
            var provider = new KeyProvider(player, passwordModeService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            Assert.Equal(new[] { "1" }, processedKeys.Single().Input);
        }
Exemplo n.º 14
0
        public void keyprovider_detects_windows_key_presses()
        {
            // arrange
            var player   = KeyStreams.WinkeyE();
            var provider = new KeyProvider(player, passwordModeService);

            // act
            var processedKeys = ToEnumerable(provider, player);

            // assert
            //TODO I think for this case we need to use the TestScheduler.. Someone that knows Rx can fix this test :)
            //Assert.Equal(new[] { "Win", "E" }, processedKeys.Single().Input);
        }
Exemplo n.º 15
0
        public async Task shift_is_not_outputted_when_is_being_used_as_a_modifier_key()
        {
            // arrange
            var player   = KeyStreams.ShiftL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert

            Assert.Equal(new[] { "L" }, processedKeys.Single().Input);
        }
        public void key_with_modifiers_raises_a_new_message()
        {
            // arrange
            var keySequence = KeyStreams.LetterL()
                              .Concat(KeyStreams.CtrlShiftL())
                              .ToObservable();
            var sut = CreateMessageProvider(keySequence);

            // act
            var messages = sut.GetMessageStream().ToList().Single();

            // assert
            Assert.Equal(2, messages.Count);
        }
Exemplo n.º 17
0
        public void recognises_shortcuts()
        {
            // arrange
            messageProvider.Subscribe(this);
            shortcutProvider.GetShortcutsMatching(Arg.Any <IEnumerable <KeyPress> >())
            .Returns(new [] { new KeyShortcut("MyShortcut", new KeyPressDefinition(Keys.L, shiftPressed: true, controlPressed: true)) });

            // act
            KeyStreams.CtrlShiftL().Play(interceptKeysSource);

            // assert
            Assert.Equal(1, messages.Count);
            Assert.Equal("MyShortcut", messages[0].ShortcutName);
        }
Exemplo n.º 18
0
        public async Task no_output_with_no_match_filter()
        {
            // arrange
            settingsProvider.GetSettings <PopupSettings>().Returns(new PopupSettings()
            {
                ProcessFilterExpression = "notepad"
            });
            var player   = KeyStreams.LetterL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(0, processedKeys.Count);
        }
Exemplo n.º 19
0
        public void does_not_show_shortcut_name_on_partial_match()
        {
            // arrange
            messageProvider.Subscribe(this);
            shortcutProvider.GetShortcutsMatching(Arg.Any <IEnumerable <KeyPress> >())
            .Returns(new[] { new KeyShortcut("SomeShortcut",
                                             new KeyPressDefinition(Keys.U, controlPressed: true),
                                             new KeyPressDefinition(Keys.L)) });

            // act
            KeyStreams.CtrlU().Play(interceptKeysSource);

            // assert
            Assert.Equal(1, messages.Count);
            Assert.NotEqual("SomeShortcut", messages[0].ShortcutName);
        }
Exemplo n.º 20
0
        public void recognises_shortcuts()
        {
            // arrange
            messageProvider.GetMessageStream(keysStream).Subscribe(value => messages.Add(value));
            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("MyShortcut", new KeyPressDefinition(Keys.L, shiftPressed: true, controlPressed: true))
            });

            // act
            KeyStreams.CtrlShiftL().Play(interceptKeysSource);

            // assert
            Assert.Equal(1, messages.Count);
            Assert.Equal("MyShortcut", messages[0].ShortcutName);
        }
Exemplo n.º 21
0
        public void does_not_show_key_press_on_partial_match()
        {
            // arrange
            messageProvider.GetMessageStream(keysStream).Subscribe(value => messages.Add(value));
            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            KeyStreams.CtrlU().Play(interceptKeysSource);

            // assert
            Assert.Equal(0, messages.Count);
        }
Exemplo n.º 22
0
        public async Task output_with_matching_filter()
        {
            // arrange
            string currentProcessName = AssociatedProcessUtilities.GetAssociatedProcess().ProcessName;

            settingsProvider.GetSettings <PopupSettings>().Returns(new PopupSettings()
            {
                ProcessFilterExpression = currentProcessName
            });
            var player   = KeyStreams.LetterL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService, settingsProvider);

            // act
            var processedKeys = await provider.GetKeyStream().ToList();

            // assert
            Assert.Equal(new[] { "l" }, processedKeys.Single().Input);
        }
        public void recognises_shortcuts()
        {
            // arrange
            var keySequence = KeyStreams.CtrlShiftL().ToObservable();
            var sut         = CreateMessageProvider(keySequence);

            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("MyShortcut", new KeyPressDefinition(Keys.L, shiftPressed: true, controlPressed: true))
            });

            // act
            var messages = sut.GetMessageStream().ToList().Single();

            // assert
            Assert.Equal(1, messages.Count);
            Assert.Equal("MyShortcut", messages[0].ShortcutName);
        }
        public void does_not_show_key_press_on_partial_match()
        {
            // arrange
            var keySequence = KeyStreams.CtrlU().ToObservable();
            var sut         = CreateMessageProvider(keySequence);

            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            var messages = sut.GetMessageStream().ToList().Single();

            // assert
            Assert.Equal(0, messages.Count);
        }
Exemplo n.º 25
0
        public void produces_two_messages_when_shortcut_is_broken()
        {
            // arrange
            messageProvider.GetMessageStream(keysStream).Subscribe(value => messages.Add(value));
            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            KeyStreams.CtrlU().Play(interceptKeysSource);
            KeyStreams.Number1().Play(interceptKeysSource);

            // assert
            Assert.Equal(2, messages.Count);
            Assert.Equal("Ctrl + U", string.Join("", messages[0].Text));
            Assert.Equal("1", string.Join("", messages[1].Text));
        }
Exemplo n.º 26
0
        public async Task does_show_shortcut_name_on_full_match()
        {
            // arrange
            var keySequence = KeyStreams.CtrlU()
                              .Concat(KeyStreams.LetterL())
                              .ToObservable();
            var sut = CreateMessageProvider(keySequence);

            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            var messages = await sut.GetMessageStream().ToList();

            // assert
            Assert.Equal(1, messages.Count);
            Assert.Equal("SomeShortcut", messages[0].ShortcutName);
        }
        public void produces_two_messages_when_shortcut_is_broken()
        {
            // arrange
            var keySequence = KeyStreams.CtrlU()
                              .Concat(KeyStreams.Number1())
                              .ToObservable();
            var sut = CreateMessageProvider(keySequence);

            shortcutProvider.GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            var messages = sut.GetMessageStream().ToList().Single();

            // assert
            Assert.Equal(2, messages.Count);
            Assert.Equal("Ctrl + U", string.Join("", messages[0].Text));
            Assert.Equal("1", string.Join("", messages[1].Text));
        }
Exemplo n.º 28
0
        public void keeps_order_of_streams()
        {
            // arrange
            messageProvider.GetMessageStream(keysStream).Subscribe(value => messages.Add(value));
            shortcutProvider
            .GetShortcutsStartingWith(Arg.Any <KeyPress>())
            .Returns(new List <KeyShortcut> {
                new KeyShortcut("SomeShortcut",
                                new KeyPressDefinition(Keys.U, controlPressed: true),
                                new KeyPressDefinition(Keys.L))
            });

            // act
            KeyStreams.CtrlU().Play(interceptKeysSource);
            KeyStreams.LetterL().Play(interceptKeysSource);
            KeyStreams.Number1().Play(interceptKeysSource);
            KeyStreams.LetterL().Play(interceptKeysSource);

            // assert
            Assert.Equal(2, messages.Count);
            Assert.Equal("Ctrl + U, l [SomeShortcut]", string.Join("", messages[0].Text));
            Assert.Equal("SomeShortcut", messages[0].ShortcutName);
            Assert.Equal("1l", string.Join("", messages[1].Text));
        }