示例#1
0
        public void CtorFindDoubleParameterNegativeLike()
        {
            var target = new CtorDoubleParamOnly(null, null);
            const BindingFlags bflags = BindingFlags.Public | BindingFlags.Instance;

            // when given an other than a string[] or a type[]
            // should not match any ctor where
            // all arg name type pairs cannot be mapped
            // to a specific parameter uniquely in the type ctor
            TestFind(target, new { arg1 = typeof(string), nothere = typeof(string) }, bflags, true);
            TestFind(target, new { arg2 = typeof(string), nothere = typeof(string) }, bflags, true);

            //when given a type[ ]
            // should not match any ctor where
            // all passed types cannot be mapped
            // to a specific parameter uniquely in the type ctor
            TestFind(target, new[] { typeof(int) }, bflags, true);
            TestFind(target, new[] { typeof(int), typeof(string) }, bflags, true);
            TestFind(target, new[] { typeof(int), typeof(int) }, bflags, true);

            // when given a string[ ]
            // should not match any ctors with parameters
            // that cannot be mapped uniquely by name to passed string[]
            TestFind(target, new[] { "arg", "arg1" }, bflags, true);
            TestFind(target, new[] { "arg", "arg2" }, bflags, true);
            TestFind(target, new[] { "narg1", "narg2" }, bflags, true);
        }
示例#2
0
        public void CtorFindDoubleParameterPostiveEq()
        {
            var target = new CtorDoubleParamOnly(null, null);
            const BindingFlags bflags = BindingFlags.Public | BindingFlags.Instance;

            //should match when exist ctor exact match between arg name and arg type in query object
            TestFind(target, new { arg1 = typeof(string), arg2 = typeof(string) }, bflags, true);
        }
示例#3
0
        public void CtorFindDoubleParameterNegativeEq()
        {
            var target = new CtorDoubleParamOnly(null, null);
            const BindingFlags bflags = BindingFlags.Public | BindingFlags.Instance;

            TestFind(target, new { arg1 = typeof(string), arg = typeof(string) }, bflags, false);
            TestFind(target, new { arg = typeof(string), arg2 = typeof(string) }, bflags, false);
            TestFind(target, new { shouldnotfind1 = typeof(string), shouldnotfind2 = typeof(string) }, bflags, false);
        }
示例#4
0
        public void CtorFindDoubleParameterPositiveLike()
        {
            var target = new CtorDoubleParamOnly(null, null);
            const BindingFlags bflags = BindingFlags.Public | BindingFlags.Instance;

            //should match all ctor where at least one param name and type matching query obj
            TestFind(target, new { arg1 = typeof(string) }, bflags, true);
            TestFind(target, new { arg2 = typeof(string) }, bflags, true);

            //should match all ctor where at least one param type matches a type in query obj
            TestFind(target, new[] { typeof(string) }, bflags, true);
            TestFind(target, new[] { typeof(string), typeof(string) }, bflags, true);

            //when given an array of strings should match ctors with parameters that contain matching names
            TestFind(target, new[] { "arg1" }, bflags, true);
            TestFind(target, new[] { "arg2" }, bflags, true);
            TestFind(target, new[] { "arg1", "arg2" }, bflags, true);
        }