Criteria that is satisfied if the System.Type of each of the parameters of a given System.Reflection.MethodInfo matches each of the parameter System.Types of a given System.Reflection.MethodInfo.

If no System.Type array is passed to the overloaded constructor, any method that has no parameters will satisfy an instance of this class. The same effect could be achieved by passing the System.Type.EmptyTypes array to the overloaded constructor.

Inheritance: ICriteria
コード例 #1
0
	    public void IsNotSatisfiedWhenOnlyFinalParamMatches()
	    {
            MethodParametersCriteria criteria = new MethodParametersCriteria(
          new Type[] { typeof(object), typeof(object), typeof(TestObject) });
            MethodInfo method = GetType().GetMethod("BoJangles");
            Assert.IsFalse(criteria.IsSatisfied(method), "Was satisified with a method that only matches on the final parameter.");
	    }
コード例 #2
0
        public void IsSatisfiedWithNoParametersByDefault()
        {
            MethodParametersCriteria criteria = new MethodParametersCriteria();
            MethodInfo method = GetType().GetMethod("Foo");

            Assert.IsTrue(criteria.IsSatisfied(method), "Was not satisified with a method that takes no parameters by default.");
        }
コード例 #3
0
 public void IsNotSatisfiedIsPolymorphic () 
 {
     // i.e. derived types satisfy the criteria if a base type or interface is
     // specified as one of the parameter types
     MethodParametersCriteria criteria
         = new MethodParametersCriteria (new Type [] {typeof (TestObject)});
     MethodInfo method = GetType ().GetMethod ("Diddly");
     Assert.IsFalse(criteria.IsSatisfied (method), "Was not satisified with a method that takes a base class as a parameter.");
 }
コード例 #4
0
        public void IsSatisfied () 
        {
            MethodParametersCriteria criteria  = new MethodParametersCriteria (
                new Type [] {typeof (string), typeof (DBNull), typeof (TestObject)});
            MethodInfo method = GetType ().GetMethod ("BoJangles");
            Assert.IsTrue (criteria.IsSatisfied (method), "Was not satisified with a method that takes a whole buncha parameters.");

            method = GetType ().GetMethod ("BadBobbyBoJangles");
            Assert.IsFalse (criteria.IsSatisfied (method), "Was satisified with a (bad) method that takes a whole buncha parameters.");
        }
コード例 #5
0
 public void IsSatisfiedWithParamsParameters()
 {
     MethodParametersCriteria criteria = new MethodParametersCriteria(new Type[] { typeof(int), typeof(string[]) });
     MethodInfo method = GetType().GetMethod("ParamsParameters");
     Assert.IsTrue(criteria.IsSatisfied(method), "Was not satisified with a method that takes a parameter array ('params') as a parameter.");
 }
コード例 #6
0
 public void IsSatisfiedWithNoParametersByDefault () 
 {
     MethodParametersCriteria criteria = new MethodParametersCriteria ();
     MethodInfo method = GetType ().GetMethod ("Foo");
     Assert.IsTrue (criteria.IsSatisfied (method), "Was not satisified with a method that takes no parameters by default.");
 }
コード例 #7
0
 public void IsNotSatisfiedWithNull () {
     MethodParametersCriteria criteria = new MethodParametersCriteria ();
     Assert.IsFalse (criteria.IsSatisfied (null), "Was satisified with null.");
 }