示例#1
0
        /// <summary>
        /// Return an IEnumerable providing test cases for use in
        /// running a parameterized test.
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public IEnumerable <ITestCaseData> GetTestCasesFor(MethodInfo method)
        {
            List <ITestCaseData> testCases = new List <ITestCaseData>();

            foreach (DataAttribute attr in method.GetCustomAttributes(typeof(DataAttribute), false))
            {
                ITestCaseSource source = attr as ITestCaseSource;
                if (source != null)
                {
                    // TODO: Create a class to handle exceptions for NUnitLite
                    foreach (ITestCaseData testCase in ((ITestCaseSource)attr).GetTestCasesFor(method))
                    {
                        testCases.Add(testCase);
                    }
                    continue;
                }
            }

            return(testCases);
        }
示例#2
0
        public IEnumerable <ITestCaseData> GetTestCasesFor(MethodInfo method)
        {
            List <ITestCaseData> list = new List <ITestCaseData>();

            object[] customAttributes = method.GetCustomAttributes(typeof(DataAttribute), inherit: false);
            for (int i = 0; i < customAttributes.Length; i++)
            {
                DataAttribute   dataAttribute  = (DataAttribute)customAttributes[i];
                ITestCaseSource testCaseSource = dataAttribute as ITestCaseSource;
                if (testCaseSource == null)
                {
                    continue;
                }
                foreach (ITestCaseData item in ((ITestCaseSource)dataAttribute).GetTestCasesFor(method))
                {
                    list.Add(item);
                }
            }
            return(list);
        }
 public void Release()
 {
     DataSource = null;
     Args = null;
 }