Exemple #1
0
        private void CheckValuesWithinTolerance(string methodName, params object[] expected)
        {
            MethodInfo      method = GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
            ParameterInfo   param  = method.GetParameters()[0];
            ValuesAttribute attr   = param.GetCustomAttributes(typeof(ValuesAttribute), false)[0] as ValuesAttribute;

            Assert.That(attr.GetData(param), Is.EqualTo(expected).Within(0.000001));
        }
        private void CheckValues(string methodName, params object[] expected)
        {
            MethodInfo      method = GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
            ParameterInfo   param  = method.GetParameters()[0];
            ValuesAttribute attr   = param.GetCustomAttributes(typeof(ValuesAttribute), false)[0] as ValuesAttribute;

            Assert.That(attr.GetData(new ParameterWrapper(new MethodWrapper(GetType(), method), param)), Is.EqualTo(expected));
        }
        private static string GenerateEventValues(EventInfo eventInfo)
        {
            string values = "";

            ValuesAttribute valuesAttr = eventInfo.GetCustomAttribute <ValuesAttribute>();

            if (valuesAttr != null)
            {
                values += "[Values(\"" + valuesAttr.Name + "\")]\n";
            }

            return(values);
        }
        private static string GenerateActionValues(MethodInfo method)
        {
            string values = "";

            ValuesAttribute valuesAttr = method.GetCustomAttribute <ValuesAttribute>();

            if (valuesAttr != null)
            {
                values += "[Values(\"" + valuesAttr.Name + "\")]\n";
            }

            return(values);
        }
        private static string GenerateSetterValues(PropertyInfo property)
        {
            string values = "";

            ValuesAttribute valuesAttr = property.GetCustomAttribute <ValuesAttribute>();

            if (valuesAttr != null)
            {
                values += "[Values(\"" + valuesAttr.Name + "\")]\n";
            }

            return(values);
        }