コード例 #1
0
        public void CanDifferentiateAgainstEmptyArgs()
        {
            // Arrange
            MethodDefinitionComparer target = new MethodDefinitionComparer();

            Type[] typeArgs = 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, Type.EmptyTypes);
            bool actual;

            // Act
            actual = target.Equals(x, y);

            // Assert
            Verify.That(actual).IsFalse()
            .Now();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }