private static void ExtractParameterizedMethodsAndTheories(NUnitDiscoveryTestFixture tf, XElement node)
        {
            const string parameterizedMethod = "ParameterizedMethod";
            const string theory = "Theory";

            foreach (var child in node.Elements("test-suite"))
            {
                var type = child.Attribute(NUnitXmlAttributeNames.Type)?.Value;
                if (type != parameterizedMethod && type != "Theory" && type != "GenericMethod")
                {
                    throw new DiscoveryException($"Expected ParameterizedMethod, Theory or GenericMethod, but was {type}");
                }
                var className = child.Attribute(NUnitXmlAttributeNames.Classname)?.Value;
                var btf       = ExtractSuiteBasePropertiesClass(child);
                switch (type)
                {
                case parameterizedMethod:
                {
                    var tc = new NUnitDiscoveryParameterizedMethod(btf, className, tf);
                    ExtractTestCases(tc, child);
                    tf.AddParameterizedMethod(tc);
                    break;
                }

                case theory:
                {
                    var tc = new NUnitDiscoveryTheory(btf, className, tf);
                    tf.AddTheory(tc);
                    ExtractTestCases(tc, child);
                    break;
                }

                default:
                {
                    var tc = new NUnitDiscoveryGenericMethod(btf, className, tf);
                    tf.AddGenericMethod(tc);
                    ExtractTestCases(tc, child);
                    break;
                }
                }
            }
        }
Exemple #2
0
 public void AddParameterizedMethod(NUnitDiscoveryParameterizedMethod ts)
 {
     parameterizedMethods.Add(ts);
 }