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>();
        }