public void ReplaceEntireString() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); buffer.Replace("xyzw"); buffer.Contents.Should().Be("xyzw"); }
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"); }
public void ReplaceWithEmptyString() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); buffer.Replace(string.Empty); buffer.Contents.Should().Be("abcd"); }
public void ReplacePartOfString() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); buffer.MoveCursor(SeekOrigin.Begin, 1); buffer.Replace("xy"); buffer.Contents.Should().Be("axyd"); }
public void ReplaceWithTooLongString() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); Action replacement = () => buffer.Replace("xyzzy"); replacement.ShouldThrow <ArgumentOutOfRangeException>(); }
public void ReplaceWithNullString() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); Action replacement = () => buffer.Replace(null); replacement.ShouldThrow <ArgumentNullException>(); }
public void ReplacingAtEnd() { var buffer = new ConsoleInputBuffer(); buffer.Insert("abcd"); buffer.MoveCursor(SeekOrigin.End, 0); Action replacementAction = () => buffer.Replace('x'); replacementAction.ShouldThrow <Exception>(); }