public void Equality() { // Generate identical assembly identities. Check that they are // indeed the same. for (int i = 0; i < 1000; i++) { var name = rng.NextAsciiString(rng.Next(0, 100)); var first = new AssemblyIdentity(name); var second = new AssemblyIdentity(name); Assert.AreEqual(first, second); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); int annotationCount = rng.Next(0, 20); for (int j = 0; j < annotationCount; j++) { var key = rng.NextAsciiString(rng.Next(0, 20)); var value = rng.NextAsciiString(rng.Next(0, 100)); string oldValue; if (!first.TryGetAnnotation(key, out oldValue)) { oldValue = null; } first = first.WithAnnotation(key, value); if (oldValue != value) { Assert.AreNotEqual(first, second); } second = second.WithAnnotation(key, value); Assert.AreEqual(first, second); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); } } }