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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
public static Message MergeIfNeeded(Message previousMessage, Message newMessage) { return(ShouldCreateNewMessage(previousMessage, newMessage) ? newMessage : previousMessage.Merge(newMessage)); }
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)); }
public Message MergeIfNeeded(Message previousMessage, Message newMessage) { return ShouldCreateNewMessage(previousMessage, newMessage) ? newMessage : previousMessage.Merge(newMessage); }
public static Message MergeIfNeeded(Message previousMessage, Message newMessage, bool showCharactersSeparate) { return(ShouldCreateNewMessage(previousMessage, newMessage, showCharactersSeparate) ? newMessage : previousMessage.Merge(newMessage)); }