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

            history.EntryCount.Should().Be(0);
            history.CurrentEntry.Should().BeNull();
            history.MoveCursor(SeekOrigin.Current, 0).Should().BeTrue();
            history.MoveCursor(SeekOrigin.Current, 1).Should().BeFalse();
            history.MoveCursor(SeekOrigin.Current, -1).Should().BeFalse();
        }
Esempio n. 2
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. 3
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");

            Action bogusMovement = () => history.MoveCursor((SeekOrigin)0x10, 0);

            bogusMovement.ShouldThrow <ArgumentOutOfRangeException>();
        }
Esempio n. 4
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");
        }