Ejemplo n.º 1
0
        public void message_does_not_group_messages_from_different_processes_together()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Up, KeyDirection.Down, false, false, false), false, new[] { "Up" }));

            // act
            message.Merge(new Message(new KeyPress(fakeProcess2, new InterceptKeyEventArgs(Keys.Down, KeyDirection.Down, false, false, false), false, new[] { "Down" })));

            // assert
            Assert.Equal("↑↓", string.Join(string.Empty, message.Text));
        }
Ejemplo n.º 2
0
        public void multiple_shortcuts_have_comma_inserted_between_input()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" }));

            // act
            message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.T, KeyDirection.Down, false, true, false), false, new[] { "Control", "T" })));

            // assert
            Assert.Equal("Control + R, Control + T", string.Join(string.Empty, message.Text));
        }
Ejemplo n.º 3
0
        public void message_does_not_group_letter_and_backspace()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "a" }));

            // act
            message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "Back" })));

            // assert
            Assert.Equal("aBack", string.Join(string.Empty, message.Text));
        }
Ejemplo n.º 4
0
        public void message_does_not_group_letter_and_backspace()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "a" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "Back" })));

            // assert
            Assert.Equal("aBack", string.Join(string.Empty, result.Text));
        }
Ejemplo n.º 5
0
        public void message_groups_two_equal_arrow_key_presses_together()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Down, KeyDirection.Down, false, false, false), false, new[] { "Down" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Down, KeyDirection.Down, false, false, false), false, new[] { "Down" })));

            // assert
            Assert.Equal("↓ x 2 ", string.Join(string.Empty, result.Text));
        }
Ejemplo n.º 6
0
        public void message_groups_multiple_backspace_key_presses_together()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "Back" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "Back" })));

            // assert
            Assert.Equal("Back x 2 ", string.Join(string.Empty, result.Text));
        }
Ejemplo n.º 7
0
        public void message_groups_multiple_equal_arrow_key_presses_together()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Down, KeyDirection.Down, false, false, false), false, new[] { "Down" }));

            // act
            message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Down, KeyDirection.Down, false, false, false), false, new[] { "Down" })));

            // assert
            Assert.Equal("↓ x 2 ", string.Join(string.Empty, message.Text));
        }
Ejemplo n.º 8
0
        public void message_does_not_group_different_letters()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "a" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "b" })));

            // assert
            var expected = string.Join(string.Empty, result.Text);
            Assert.Equal("ab", expected);
        }
Ejemplo n.º 9
0
        public void MessageTimeoutIsStartedAgainIfMessageIsUpdated()
        {
            var message = new Message(A);

            sut.Start();
            ProvideMessage(message);
            testScheduler.AdvanceBy(TimeSpan.FromSeconds(3).Ticks);
            message.Merge(new Message(A));
            testScheduler.AdvanceBy(TimeSpan.FromSeconds(3).Ticks);

            message.IsDeleting.ShouldBe(false);
            keysCollection.ShouldContain(message);
        }
Ejemplo n.º 10
0
        public void message_does_not_group_different_letters()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "a" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.Back, KeyDirection.Down, false, false, false), false, new[] { "b" })));

            // assert
            var expected = string.Join(string.Empty, result.Text);

            Assert.Equal("ab", expected);
        }
Ejemplo n.º 11
0
        public void multiple_shortcuts_duplicate_shortcuts_are_grouped()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" })));

            // assert
            string actual = string.Join(string.Empty, result.Text);

            Assert.Equal("Control + R x 2 ", actual);
        }
Ejemplo n.º 12
0
        public void UnsubscribesFromMessageUpdatesAfterDeleteTimeout()
        {
            var message = new Message(A);

            sut.Start();
            ProvideMessage(message);
            testScheduler.AdvanceBy(TimeSpan.FromSeconds(5).Ticks);
            message.IsDeleting = false;
            message.Merge(new Message(A)); // This will trigger an update of the message
            testScheduler.AdvanceBy(5);
            testScheduler.AdvanceBy(TimeSpan.FromSeconds(5).Ticks);

            // If we didn't unsubscribe to updates we would have triggered another inner sequence which would try to delete again.
            message.IsDeleting.ShouldBe(false);
        }
Ejemplo n.º 13
0
        public void MessageTimeoutIsStartedAgainIfMessageIsUpdated()
        {
            var expected        = messageA.Merge(new Message(A));
            var messageSequence = testScheduler.CreateColdObservable(
                ReactiveTest.OnNext(MessageAOnNextTick, messageA),
                ReactiveTest.OnNext(3.Seconds(), expected)
                );

            var sut = CreateKeysController(messageSequence);

            sut.Start();
            testScheduler.AdvanceBy(6.Seconds());

            messages.Single().IsDeleting.ShouldBe(false);
            messages.Single().ShouldBe(expected);
        }
Ejemplo n.º 14
0
        public void MultiMerge()
        {
            var message1 = new Message(Down);
            var message2 = message1.Merge(new Message(Down));
            var message3 = message2.Merge(new Message(Down));

            var expected        = message3;
            var messageSequence = testScheduler.CreateColdObservable(
                ReactiveTest.OnNext(0.1.Seconds(), message1),
                ReactiveTest.OnNext(0.2.Seconds(), message2),
                ReactiveTest.OnNext(0.3.Seconds(), message3)
                );

            var sut = CreateKeysController(messageSequence);

            sut.Start();
            testScheduler.AdvanceBy(1.Seconds());

            messages.Single().IsDeleting.ShouldBe(false);
            messages.Single().ShouldBe(expected);
        }
Ejemplo n.º 15
0
 public static Message MergeIfNeeded(Message previousMessage, Message newMessage)
 {
     return(ShouldCreateNewMessage(previousMessage, newMessage)
         ? newMessage
         : previousMessage.Merge(newMessage));
 }
Ejemplo n.º 16
0
        public void multiple_shortcuts_have_comma_inserted_between_input()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.T, KeyDirection.Down, false, true, false), false, new[] { "Control", "T" })));

            // assert
            Assert.Equal("Control + R, Control + T", string.Join(string.Empty, result.Text));
        }
Ejemplo n.º 17
0
 public Message MergeIfNeeded(Message previousMessage, Message newMessage)
 {
     return ShouldCreateNewMessage(previousMessage, newMessage)
         ? newMessage
         : previousMessage.Merge(newMessage);
 }
Ejemplo n.º 18
0
 public static Message MergeIfNeeded(Message previousMessage, Message newMessage, bool showCharactersSeparate)
 {
     return(ShouldCreateNewMessage(previousMessage, newMessage, showCharactersSeparate)
         ? newMessage
         : previousMessage.Merge(newMessage));
 }
Ejemplo n.º 19
0
        public void MultiMerge()
        {
            var message1 = new Message(Down);
            var message2 = message1.Merge(new Message(Down));
            var message3 = message2.Merge(new Message(Down));

            var expected = message3;
            var messageSequence = testScheduler.CreateColdObservable(
                ReactiveTest.OnNext(0.1.Seconds(), message1),
                ReactiveTest.OnNext(0.2.Seconds(), message2),
                ReactiveTest.OnNext(0.3.Seconds(), message3)
                );

            var sut = CreateKeysController(messageSequence);

            sut.Start();
            testScheduler.AdvanceBy(1.Seconds());

            messages.Single().IsDeleting.ShouldBe(false);
            messages.Single().ShouldBe(expected);
        }
Ejemplo n.º 20
0
        public void multiple_shortcuts_duplicate_shortcuts_are_grouped()
        {
            // arrange
            var message = new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" }));

            // act
            var result = message.Merge(new Message(new KeyPress(fakeProcess, new InterceptKeyEventArgs(Keys.R, KeyDirection.Down, false, true, false), false, new[] { "Control", "R" })));

            // assert
            string actual = string.Join(string.Empty, result.Text);

            Assert.Equal("Control + R x 2 ", actual);
        }