public void ToStringOverSizeThrowsOverflow() { using (var buffer = new StringBuffer()) { var length = buffer.GetType().GetField("_length", BindingFlags.NonPublic | BindingFlags.Instance); length.SetValue(buffer, (uint)int.MaxValue + 1); Action action = () => buffer.ToString(); action.ShouldThrow<OverflowException>(); } }
public void SubStringImplicitCountOverMaxStringThrows() { using (var buffer = new StringBuffer()) { var length = buffer.GetType().GetField("_length", BindingFlags.NonPublic | BindingFlags.Instance); length.SetValue(buffer, (uint)int.MaxValue + 1); Action action = () => buffer.SubString(startIndex: 0, count: -1); action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("count"); } }