Beispiel #1
0
        public static bool RunTest()
        {
            GenericFooCallback <bool> callback = Poo <bool>;

            callback += new GenericFooCallback <bool>(Poo <bool>);

            var obj  = new GenericClass <int>();
            var obj2 = new GenericClass <object>();
            var obj3 = new GenericClass2 <double>();
            var obj4 = (GenericClass <double>)obj3;
            var obj5 = new GenericClass <long> .B <object>();

            callback += obj.TestVirt <bool>;
            obj.i     = 1;
            obj.p     = 2;
            obj2.i    = obj;
            obj2.p    = obj;
            obj5.i    = 77;
            obj5.i2   = null;
            return(!callback(true) &&
                   Poo <int>(true) == 0 && Poo <object>(true) == null &&
                   obj.Foo(1) == 1 && obj2.Foo(obj) == obj &&
                   obj.Foo2 <object>(obj, new GenericClass <object>()) == 2 && obj2.Foo2(obj2, new GenericClass <object>()) == obj &&
                   obj.Boo <object>(5, obj2) == obj2 &&
                   obj4.MyVirt <object>(obj3) && obj4.MyVirt(string.Empty) &&
                   obj3.MyVirt2 <object>(obj3) &&
                   obj5.Aaa <object>(null));
        }
Beispiel #2
0
        public void CreateByNameInGenericClass()
        {
            var obj = new GenericClass <string>();

            Pattern.CreateByName(it => obj.Foo());

            var className = $"{typeof(GenericClass<string>)}::{nameof(GenericClass<string>.Foo)}";

            Assert.That(context.Patterns.Select(info => info.Method.ToString()), Is.EquivalentTo(new []
            {
                $"{className}()",
                $"{className}(System.String)",
            }));
        }