private static string GenerateNewUniqueValue(Type interfaceType, RandomStringValueProperty field) { string randomString = GenerateRandomString(field.Attribute.Length); if (field.Attribute.CheckCollisions) { bool uniqueValueFound = false; const int tries = 2; for (int i = 0; i < tries; i++) { if (!ValueIsInUse(interfaceType, field.Property, randomString, field.IsKey)) { uniqueValueFound = true; break; } randomString = GenerateRandomString(field.Attribute.Length); } if (!uniqueValueFound) { Verify.That(uniqueValueFound, "Failed to generate a unique random string value after {0} tries. Field name: {1}, random value length: {2}", tries, field.Property.Name, field.Attribute.Length); } } return randomString; }