System.Text.Tests.StringBuilderTests.Append_CharPointer_Invalid C# (CSharp) Method

Append_CharPointer_Invalid() private method

private Append_CharPointer_Invalid ( ) : void
return void
        public static unsafe void Append_CharPointer_Invalid()
        {
            var builder = new StringBuilder();
            Assert.Throws<NullReferenceException>(() => builder.Append(null, 2)); // Value is null

            builder = new StringBuilder(0, 5);
            builder.Append("Hello");

            Assert.Throws<ArgumentOutOfRangeException>("valueCount", () =>
            {
                fixed (char* value = new char[0]) { builder.Append(value, -1); } // Value count < 0
        });

            Assert.Throws<ArgumentOutOfRangeException>("valueCount", () =>
            {
                fixed (char* value = new char[] { 'a' }) { builder.Append(value, 1); } // New length > builder.MaxCapacity 
        });
        }
StringBuilderTests