Criteria that is satisfied if the number of parameters to a given System.Reflection.MethodBase matches an arbitrary number.

This class supports checking the parameter count of both methods and constructors.

Default parameters, etc need to taken into account.

Наследование: ICriteria
 public void Instantiation () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
     Assert.AreEqual (0, criteria.ExpectedParameterCount);
     criteria = new MethodParametersCountCriteria (10);
     Assert.AreEqual (10, criteria.ExpectedParameterCount);
 }
Пример #2
0
        public void IsSatisfiedWithTwoParameters()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria(2);
            MethodInfo method = GetType().GetMethod("TwoParameters", BindingFlags.Public | BindingFlags.Instance);

            Assert.IsTrue(criteria.IsSatisfied(method));
        }
Пример #3
0
        public void Instantiation()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria();

            Assert.AreEqual(0, criteria.ExpectedParameterCount);
            criteria = new MethodParametersCountCriteria(10);
            Assert.AreEqual(10, criteria.ExpectedParameterCount);
        }
        public void IsSatisfiedWithNoParameter () 
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
            MethodInfo method = GetType ().GetMethod ("NoParameter", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue (criteria.IsSatisfied (method));

            criteria = new MethodParametersCountCriteria(0);
            method = GetType().GetMethod("NoParameter", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));

            criteria = new MethodParametersCountCriteria();
            criteria.ExpectedParameterCount = 0;
            method = GetType().GetMethod("NoParameter", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));
        }
Пример #5
0
        public void IsSatisfiedWithNoParameter()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria();
            MethodInfo method = GetType().GetMethod("NoParameter", BindingFlags.Public | BindingFlags.Instance);

            Assert.IsTrue(criteria.IsSatisfied(method));

            criteria = new MethodParametersCountCriteria(0);
            method   = GetType().GetMethod("NoParameter", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));

            criteria = new MethodParametersCountCriteria();
            criteria.ExpectedParameterCount = 0;
            method = GetType().GetMethod("NoParameter", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));
        }
        public void IsSatisfiedWithParamsParameters () 
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria(1);
            MethodInfo method = GetType().GetMethod("ParamsParameters", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsFalse(criteria.IsSatisfied(method));

            criteria = new MethodParametersCountCriteria(2);
            method = GetType().GetMethod("ParamsParameters", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));

            criteria = new MethodParametersCountCriteria (3);
            method = GetType().GetMethod("ParamsParameters", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue (criteria.IsSatisfied (method));

            criteria = new MethodParametersCountCriteria(5);
            method = GetType().GetMethod("ParamsParameters", BindingFlags.Public | BindingFlags.Instance);
            Assert.IsTrue(criteria.IsSatisfied(method));
        }
 public void IsSatisfiedWithOneParameter () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria (1);
     MethodInfo method = GetType().GetMethod("OneParameter", BindingFlags.Public | BindingFlags.Instance);
     Assert.IsTrue (criteria.IsSatisfied (method));
 }
 public void BailsWhenExpectedParameterCountSetToLessThanZero () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
     criteria.ExpectedParameterCount = -12;
 }
 public void InstantiationBailsWithParameterCountSetToLessThanZero () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria (-10);
 }
 public void IsNotSatisfiedWithNull () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
     Assert.IsFalse (criteria.IsSatisfied (null));
 }
Пример #11
0
        public void BailsWhenExpectedParameterCountSetToLessThanZero()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria();

            Assert.Throws <ArgumentOutOfRangeException>(() => criteria.ExpectedParameterCount = -12);
        }
Пример #12
0
        public void IsNotSatisfiedWithNull()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria();

            Assert.IsFalse(criteria.IsSatisfied(null));
        }
        public void BailsWhenExpectedParameterCountSetToLessThanZero()
        {
            MethodParametersCountCriteria criteria = new MethodParametersCountCriteria();

            criteria.ExpectedParameterCount = -12;
        }
 public void InstantiationBailsWithParameterCountSetToLessThanZero()
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria(-10);
 }
 public void BailsWhenExpectedParameterCountSetToLessThanZero () 
 {
     MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
     Assert.Throws<ArgumentOutOfRangeException>(() => criteria.ExpectedParameterCount = -12);
 }