public void AppendOverCountWithIndexThrows() { using (var buffer = new StringBuffer()) { Action action = () => buffer.Append("A", startIndex: 1, count: 1); action.ShouldThrow<ArgumentOutOfRangeException>(); } }
public void AppendNegativeIndexThrows() { using (var buffer = new StringBuffer()) { Action action = () => buffer.Append("a", startIndex: -1); action.ShouldThrow<ArgumentOutOfRangeException>(); } }
public void AppendNullStringBufferThrows() { using (var buffer = new StringBuffer()) { Action action = () => buffer.Append((StringBuffer)null); action.ShouldThrow<ArgumentNullException>(); } }
public void AppendTests(string source, string value, int startIndex, int count, string expected) { // From string using (var buffer = new StringBuffer(source)) { buffer.Append(value, startIndex, count); buffer.ToString().Should().Be(expected); } // From buffer using (var buffer = new StringBuffer(source)) using (var valueBuffer = new StringBuffer(value)) { if (count == -1) buffer.Append(valueBuffer, (ulong)startIndex); else buffer.Append(valueBuffer, (ulong)startIndex, (ulong)count); buffer.ToString().Should().Be(expected); } }
public void SubStringIndexPlusCountCombinedOutOfRangeThrows() { using (var buffer = new StringBuffer("a")) { Action action = () => buffer.SubString(startIndex: 1, count: 1); action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex"); buffer.Append("b"); action.ShouldNotThrow<ArgumentOutOfRangeException>(); action = () => buffer.SubString(startIndex: 1, count: 2); action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("count"); } }
public void SubStringIndexOverLengthThrows() { using (var buffer = new StringBuffer()) { Action action = () => buffer.SubString(startIndex: 1); action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex"); buffer.Append("a"); action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex"); buffer.Append("b"); action.ShouldNotThrow(); } }