Пример #1
0
        public void ReplaceEntireString()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");

            buffer.Replace("xyzw");
            buffer.Contents.Should().Be("xyzw");
        }
Пример #2
0
        public void ReplaceOneChar()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.Current, 1).Should().BeTrue();
            buffer.Replace('x');
            buffer.Contents.Should().Be("axcd");
        }
Пример #3
0
        public void ReplaceWithEmptyString()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");

            buffer.Replace(string.Empty);
            buffer.Contents.Should().Be("abcd");
        }
Пример #4
0
        public void ReplacePartOfString()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");

            buffer.MoveCursor(SeekOrigin.Begin, 1);
            buffer.Replace("xy");
            buffer.Contents.Should().Be("axyd");
        }
Пример #5
0
        public void ReplaceWithTooLongString()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");

            Action replacement = () => buffer.Replace("xyzzy");

            replacement.ShouldThrow <ArgumentOutOfRangeException>();
        }
Пример #6
0
        public void ReplaceWithNullString()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");

            Action replacement = () => buffer.Replace(null);

            replacement.ShouldThrow <ArgumentNullException>();
        }
Пример #7
0
        public void ReplacingAtEnd()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.End, 0);

            Action replacementAction = () => buffer.Replace('x');

            replacementAction.ShouldThrow <Exception>();
        }