public void ShouldImplementEquality() { var hello = new StringType("Hello"); var there = new StringType("There"); var otherHello = new OtherStringType("Hello"); var otherHello2 = new OtherStringType("Hello"); Assert.That(hello.Equals(there), Is.False); Assert.That(hello.Equals(otherHello), Is.False); Assert.That(hello.Equals(otherHello2), Is.False); Assert.That(there.Equals(hello), Is.False); Assert.That(there.Equals(otherHello), Is.False); Assert.That(otherHello.Equals(otherHello2), Is.True); }
public string GetRandomString(StringType type, int length) { string result = string.Empty; if ((!type.Equals(StringType.None)) && (length > 0)) { int charcode = 0; char[] chars = new char[length]; for (int i = 0; i < length; i++) { switch (type) { case StringType.Unicode: charcode = GetUnicodeCharacterValue(); break; case StringType.Alpha: charcode = 65 + valueGen.Next(0, 26); break; case StringType.AlphaNumeric: charcode = valueGen.Next(0, 36); if (charcode < 10) { charcode += 48; } else { charcode += 55; } break; case StringType.Numeric: charcode = 48 + valueGen.Next(0, 10); break; case StringType.Cased: charcode = valueGen.Next(0, 52); if (charcode < 26) { charcode += 65; } else { charcode += 71; } break; } chars[i] = (char)charcode; } for (int i = 0; i < chars.Length; i++) { result += chars[i].ToString(); } chars = null; } return result; }