Example #1
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);
        }
Example #2
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);
        }
Example #3
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 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));
        }
Example #5
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));
        }