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));
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
        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);
        }
Exemple #5
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));
        }
        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));
        }
Exemple #8
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));
        }