예제 #1
0
        public void SetInstantiation_should_set_Instantiation_property_with_the_generic_method_signature_of_generic_type()
        {
            // Arrange
            var name   = "EchoOfT5OfT6OfT7OfT8OfTRetT4T8";
            var alias  = "EchoOfT5OfT6OfT7OfT8OfTRetT4T8";
            var xml    = string.Empty;
            var target = typeof(ULUnusedGeneric <, , ,>).GetMethods().First();
            var stub   = new IndirectionStub(name, alias, xml, target);

            var info = new IndirectionInfo();

            var typeGenericArgs   = new[] { typeof(sbyte), typeof(byte), typeof(short), typeof(ushort) };
            var methodGenericArgs = new[] { typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(decimal) };


            // Act
            info.SetInstantiation(target, stub.Signature, typeGenericArgs, methodGenericArgs);


            // Assert
            var expected = new[]
            {
                target.DeclaringType.MakeGenericType(typeGenericArgs[0], typeGenericArgs[1], typeGenericArgs[2], typeGenericArgs[3]),
                typeGenericArgs[3],
                methodGenericArgs[3],
                methodGenericArgs[4]
            }.Select(_ => _.ToString());

            CollectionAssert.AreEqual(expected, info.Instantiation);
        }
예제 #2
0
        public void SetInstantiation_should_set_Instantiation_property_with_the_generic_method_signature_that_contains_same_type_parameter()
        {
            // Arrange
            var name   = "GetPropertyOfTStringT";
            var alias  = "GetPropertyOfTStringT";
            var xml    = string.Empty;
            var target = typeof(ULConfigurationManager).GetMethods().First();
            var stub   = new IndirectionStub(name, alias, xml, target);

            var info = new IndirectionInfo();

            var typeGenericArgs   = Type.EmptyTypes;
            var methodGenericArgs = new[] { typeof(DayOfWeek) };


            // Act
            info.SetInstantiation(target, stub.Signature, typeGenericArgs, methodGenericArgs);


            // Assert
            var expected = new[]
            {
                typeof(string),
                methodGenericArgs[0],
                methodGenericArgs[0]
            }.Select(_ => _.ToString());

            CollectionAssert.AreEqual(expected, info.Instantiation);
        }
예제 #3
0
        public void SetInstantiation_should_set_Instantiation_property_with_the_signature_of_the_method_that_has_a_type_as_same_as_declaring_type_variation()
        {
            // Arrange
            var name   = "FugaIndirectionInfoTestDOfBarRef";
            var alias  = "FugaIndirectionInfoTestDOfBarRef";
            var xml    = string.Empty;
            var target = typeof(D <>).GetMethods().First();
            var stub   = new IndirectionStub(name, alias, xml, target);

            var info = new IndirectionInfo();

            var typeGenericArgs   = new[] { typeof(int) };
            var methodGenericArgs = Type.EmptyTypes;


            // Act
            info.SetInstantiation(target, stub.Signature, typeGenericArgs, methodGenericArgs);


            // Assert
            var expected = new[]
            {
                target.DeclaringType.MakeGenericType(typeGenericArgs[0]),
                typeof(List <>).MakeGenericType(target.DeclaringType.MakeGenericType(typeGenericArgs[0]).MakeArrayType()).MakeArrayType(2).MakeByRefType(),
                typeof(List <>).MakeGenericType(target.DeclaringType.MakeGenericType(typeGenericArgs[0]).MakeArrayType()).MakeArrayType(2)
            }.Select(_ => _.ToString());

            CollectionAssert.AreEqual(expected, info.Instantiation);
        }