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

GrowAndContract_Small() private method

private GrowAndContract_Small ( ) : void
return void
        public static void GrowAndContract_Small()
        {
            var rand = new Random(42);
            var sb = new StringBuilder(string.Empty);

            using (SecureString testString = CreateSecureString(string.Empty))
            {
                for (int loop = 0; loop < 3; loop++)
                {
                    for (int i = 0; i < 100; i++)
                    {
                        char c = (char)('a' + rand.Next(0, 26));
                        int addPos = rand.Next(0, sb.Length);
                        testString.InsertAt(addPos, c);
                        sb.Insert(addPos, c);
                        AssertEquals(sb.ToString(), testString);
                    }
                    while (sb.Length > 0)
                    {
                        int removePos = rand.Next(0, sb.Length);
                        testString.RemoveAt(removePos);
                        sb.Remove(removePos, 1);
                        AssertEquals(sb.ToString(), testString);
                    }
                }
            }
        }