コード例 #1
0
ファイル: MessageFacts.cs プロジェクト: phaufe/carnac
        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));
        }
コード例 #2
0
ファイル: MessageFacts.cs プロジェクト: phaufe/carnac
        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));
        }
コード例 #3
0
ファイル: MessageFacts.cs プロジェクト: phaufe/carnac
        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));
        }
コード例 #4
0
ファイル: MessageFacts.cs プロジェクト: bihai/carnac
        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));
        }
コード例 #5
0
ファイル: MessageFacts.cs プロジェクト: bihai/carnac
        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));
        }
コード例 #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));
        }
コード例 #7
0
ファイル: MessageFacts.cs プロジェクト: phaufe/carnac
        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));
        }
コード例 #8
0
ファイル: MessageFacts.cs プロジェクト: bihai/carnac
        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);
        }
コード例 #9
0
ファイル: KeysControllerFacts.cs プロジェクト: phaufe/carnac
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #12
0
ファイル: KeysControllerFacts.cs プロジェクト: phaufe/carnac
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #15
0
 public static Message MergeIfNeeded(Message previousMessage, Message newMessage)
 {
     return(ShouldCreateNewMessage(previousMessage, newMessage)
         ? newMessage
         : previousMessage.Merge(newMessage));
 }
コード例 #16
0
ファイル: MessageFacts.cs プロジェクト: bihai/carnac
        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));
        }
コード例 #17
0
ファイル: MessageMerger.cs プロジェクト: bihai/carnac
 public Message MergeIfNeeded(Message previousMessage, Message newMessage)
 {
     return ShouldCreateNewMessage(previousMessage, newMessage)
         ? newMessage
         : previousMessage.Merge(newMessage);
 }
コード例 #18
0
 public static Message MergeIfNeeded(Message previousMessage, Message newMessage, bool showCharactersSeparate)
 {
     return(ShouldCreateNewMessage(previousMessage, newMessage, showCharactersSeparate)
         ? newMessage
         : previousMessage.Merge(newMessage));
 }
コード例 #19
0
ファイル: KeysControllerFacts.cs プロジェクト: bihai/carnac
        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);
        }
コード例 #20
0
ファイル: MessageFacts.cs プロジェクト: bihai/carnac
        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);
        }