示例#1
0
        public void CanStoreTest()
        {
            object[] obj = new object[5];
            obj[0] = new object();
            obj[1] = new int();
            obj[2] = new float();
            obj[3] = new Action(() => { });
            obj[4] = new List<int>();

            Type[] types1 = obj.GetTypes();
            Type[] types2 = new Type[] { typeof(object), typeof(int), typeof(float), typeof(Delegate), typeof(IList<int>) };
            Assert.IsTrue(types2.CanStore(types1));
            Assert.IsFalse(types1.CanStore(types2));

            Signature s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(Int16) };
            Signature s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(object) };

            Assert.IsTrue(s2.CanStore(s1));
            Assert.IsFalse(s1.CanStore(s2));

            types1 = new Type[0];
            types2 = new Type[0];

            Assert.IsTrue(types2.CanStore(types1));
            Assert.IsTrue(types1.CanStore(types2));

             s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(void) };
             s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(void) };

             Assert.IsTrue(s2.CanStore(s1));
             Assert.IsTrue(s1.CanStore(s2));
        }