System.Security.Tests.SecureStringTests.SetAt C# (CSharp) Method

SetAt() private method

private SetAt ( ) : void
return void
        public static void SetAt()
        {
            using (SecureString testString = CreateSecureString("abc"))
            {
                testString.SetAt(2, 'f');
                AssertEquals("abf", testString);

                testString.SetAt(0, 'd');
                AssertEquals("dbf", testString);

                testString.SetAt(1, 'e');
                AssertEquals("def", testString);
            }

            string expected = CreateString(ushort.MaxValue + 1);
            using (SecureString testString = CreateSecureString(expected))
            {
                testString.SetAt(22, 'b');
                char[] chars = expected.ToCharArray();
                chars[22] = 'b';
                AssertEquals(new string(chars), testString);
            }
        }