Example #1
0
 MessageProvider CreateMessageProvider(IObservable<InterceptKeyEventArgs> keysStreamSource)
 {
     var source = Substitute.For<IInterceptKeys>();
     source.GetKeyStream().Returns(keysStreamSource);
     var desktopLockEventService = Substitute.For<IDesktopLockEventService>();
     desktopLockEventService.GetSessionSwitchStream().Returns(Observable.Never<SessionSwitchEventArgs>());
     var keyProvider = new KeyProvider(source, new PasswordModeService(), desktopLockEventService);
     return new MessageProvider(shortcutProvider, keyProvider, new PopupSettings(), new MessageMerger());
 }
Example #2
0
        public void verify_number()
        {
            // arrange
            var player = 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 shift_is_not_outputted_when_is_being_used_as_a_modifier_key()
        {
            // arrange
            var player = ShiftL();
            var provider = new KeyProvider(player, passwordModeService);

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

            // assert
            Assert.Equal(new[] { "L" }, processedKeys.Single().Input);
        }
Example #4
0
        public void key_without_shift_is_lowercase()
        {
            // arrange
            var player = LetterL();
            var provider = new KeyProvider(player, passwordModeService);

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

            // assert
            Assert.Equal(new[] { "l" }, processedKeys.Single().Input);
        }
Example #5
0
        public void ctrlshiftl_is_processed_correctly()
        {
            // arrange
            var player = CtrlShiftL();
            var provider = new KeyProvider(player, passwordModeService);

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

            // assert
            Assert.Equal(new[] { "Ctrl", "Shift", "L" }, processedKeys.Single().Input);
        }
Example #6
0
        public void verify_shift_number()
        {
            // arrange
            var player = KeyStreams.ExclaimationMark();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

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

            // assert
            Assert.Equal(new[] { "!" }, processedKeys.Single().Input);
        }
Example #7
0
        public void key_without_shift_is_lowercase()
        {
            // arrange
            var player = KeyStreams.LetterL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

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

            // assert
            Assert.Equal(new[] { "l" }, processedKeys.Single().Input);
        }
Example #8
0
        public void ctrlshiftl_is_processed_correctly()
        {
            // arrange
            var player = KeyStreams.CtrlShiftL();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

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

            // assert
            Assert.Equal(new[] { "Ctrl", "Shift", "L" }, processedKeys.Single().Input);
        }
Example #9
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
            Assert.Equal(new[] { "Win", "e" }, processedKeys.Single().Input);
        }
Example #10
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, desktopLockEventService);

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

            // assert

            Assert.Equal(new[] { "L" }, processedKeys.Single().Input);
        }
Example #11
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);
        }
Example #12
0
        public void this_is_how_to_write_a_carnac_test()
        {
            //Start off by running KeyStreamCapture, hit start capture, type what you want, hit end capture,
            //copy the code into the test, then clean it up (code gen is ugly code)... Ctrl + E, C (R# Code Cleanup) should do
            //In this example I pressed Ctrl + Shift + L

            // arrange
            var ctrlShiftLSource = CtrlShiftL();

            // act
            var provider = new KeyProvider(ctrlShiftLSource);
            //I havent got any further.. Thoughts? :P
        }
Example #13
0
        public void verify_password_mode_works()
        {
            //arrange
            var passwordInterceptKeyEventArgs = new InterceptKeyEventArgs(Keys.A, KeyDirection.Down, false, false, false);
            var passwordInterceptKeyEventArgs2 = new InterceptKeyEventArgs(Keys.B, KeyDirection.Down, false, false, false);
            var player = new KeyPlayer { passwordInterceptKeyEventArgs, passwordInterceptKeyEventArgs2 };

            var passwordService = Substitute.For<IPasswordModeService>();
            passwordService.CheckPasswordMode(Arg.Is(passwordInterceptKeyEventArgs)).Returns(true);

            var provider = new KeyProvider(player, passwordService);

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

            //assert
            Assert.Equal(1, processedKeys.Count());
        }
Example #14
0
        private IEnumerable<KeyPress> ToEnumerable(KeyProvider provider, KeyPlayer player)
        {
            var keys = new List<KeyPress>();

            provider.Subscribe(keys.Add);
            player.Play();

            return keys;
        }
Example #15
0
        public void keyprovider_detects_windows_key_presses()
        {
            // arrange
            var player = KeyStreams.WinkeyE();
            var provider = new KeyProvider(player, passwordModeService, desktopLockEventService);

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

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

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

            // assert
            Assert.Equal(new[] { "!" }, processedKeys.Single().Input);
        }