Esempio n. 1
0
        public void MovingCursor()
        {
            var history = new ConsoleHistory();

            history.Add("Oldest");
            history.Add("Middle");
            history.Add("Youngest");

            history.MoveCursor(SeekOrigin.Begin, 0);
            history.CurrentEntry.Should().Be("Oldest");

            history.MoveCursor(SeekOrigin.Begin, 1);
            history.CurrentEntry.Should().Be("Middle");

            history.MoveCursor(SeekOrigin.End, 0);
            history.CurrentEntry.Should().BeNull();

            history.MoveCursor(SeekOrigin.End, -1);
            history.CurrentEntry.Should().Be("Youngest");

            history.MoveCursor(SeekOrigin.End, -2);
            history.CurrentEntry.Should().Be("Middle");

            history.MoveCursor(SeekOrigin.End, -3);
            history.CurrentEntry.Should().Be("Oldest");

            history.MoveCursor(1);
            history.CurrentEntry.Should().Be("Middle");

            history.Invoking(h => h.MoveCursor((SeekOrigin)0x10, 0))
            .Should().Throw <ArgumentOutOfRangeException>();
        }
Esempio n. 2
0
        public void HistoryWithMax()
        {
            var history = new ConsoleHistory(2);

            history.Add("First");
            history.EntryCount.Should().Be(1);
            history.Add("Second");
            history.EntryCount.Should().Be(2);
            history.Add("Third");
            history.EntryCount.Should().Be(2);
        }
Esempio n. 3
0
        public void AddEmptyEntry()
        {
            var history = new ConsoleHistory();

            history.Add("Hello");
            history.EntryCount.Should().Be(1);

            history.Add(null);
            history.EntryCount.Should().Be(1);

            history.Add(string.Empty);
            history.EntryCount.Should().Be(1);
        }
Esempio n. 4
0
        private void PrintMessage(string message, Color color)
        {
            try
            {
                if (!IsDebug)
                {
                    return;
                }

                if (LogPlace.InvokeRequired)
                {
                    LogPlace.Invoke(new MethodInvoker(() => { SetDataToRichTextBox(LogPlace, message, color); }));
                }

                else
                {
                    SetDataToRichTextBox(LogPlace, message, color);
                }

                ConsoleHistory.Add(message);

                LogCount++;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 5
0
        public void SingleEntry()
        {
            var history = new ConsoleHistory();

            history.Add("Something");
            history.EntryCount.Should().Be(1);
            history.CurrentEntry.Should().BeNull();
            history.MoveCursor(SeekOrigin.Current, 0).Should().BeTrue();
            history.MoveCursor(SeekOrigin.Current, 1).Should().BeFalse();
            history.MoveCursor(SeekOrigin.Current, -2).Should().BeFalse();
            history.MoveCursor(SeekOrigin.Current, -1).Should().BeTrue();
            history.CurrentEntry.Should().Be("Something");
        }
Esempio n. 6
0
        public void MultipleEntries()
        {
            var history = new ConsoleHistory();

            history.Add("Older");
            history.Add("Newer");
            history.EntryCount.Should().Be(2);

            history.CurrentEntry.Should().BeNull();

            history.MoveCursor(SeekOrigin.Current, -1).Should().BeTrue();
            history.CurrentEntry.Should().Be("Newer");

            history.MoveCursor(SeekOrigin.Current, -1).Should().BeTrue();
            history.CurrentEntry.Should().Be("Older");

            history.MoveCursor(SeekOrigin.Current, 1).Should().BeTrue();
            history.CurrentEntry.Should().Be("Newer");

            history.MoveCursor(SeekOrigin.Current, 1).Should().BeTrue();
            history.MoveCursor(SeekOrigin.Current, -2).Should().BeTrue();
            history.CurrentEntry.Should().Be("Older");
        }
Esempio n. 7
0
        private void PrintMessage(string message, Color color)
        {
            try
            {
                //if (!IsDebug) return;

                if (richTextBox.InvokeRequired)
                {
                    richTextBox.Invoke(new MethodInvoker(() => { SetDataToRichTextBox(message, color); }));
                }

                else
                {
                    SetDataToRichTextBox(message, color);
                }

                ConsoleHistory.Add(message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }