public void GeneratesSameHashCodeForSamePairs() { // Arrange MethodDefinitionComparer target = new MethodDefinitionComparer(); Type[] typeArgs = new Type[] { typeof(TestClass), typeof(List <string>), typeof(int) }; Type[] typeArgs2 = new Type[] { typeof(TestClass), typeof(List <string>), typeof(int) }; string TestName = "methodname"; KeyValuePair <string, Type[]> x = new KeyValuePair <string, Type[]>(TestName, typeArgs); KeyValuePair <string, Type[]> y = new KeyValuePair <string, Type[]>(TestName, typeArgs2); int actual; int expected; // Act actual = target.GetHashCode(x); expected = target.GetHashCode(y); // Assert Verify.That(actual).IsEqualTo(expected).Now(); }
public void GeneratesDifferentHashcodeForDifferentPairs() { // Arrange MethodDefinitionComparer target = new MethodDefinitionComparer(); Type[] typeArgs = new Type[] { typeof(TestClass), typeof(List <string>), typeof(int) }; string TestName = "methodname"; Type[] typeArgs1 = new Type[] { typeof(TestClass), typeof(List <string>), typeof(double) }; string TestName1 = "methodname1"; KeyValuePair <string, Type[]> x = new KeyValuePair <string, Type[]>(TestName, typeArgs); KeyValuePair <string, Type[]> y = new KeyValuePair <string, Type[]>(TestName1, typeArgs1); int actual; int not_expected; // Act actual = target.GetHashCode(x); not_expected = target.GetHashCode(y); // Assert Verify.That(actual).IsDifferentFrom(not_expected) .Now(); }