Exemple #1
0
            public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
            {
                var explic = method.GetCustomAttributes <ExplicitAttribute>(true)
                             .Cast <IApplyToTest>()
                             .Union(method.GetCustomAttributes <IgnoreAttribute>(true))
                             .ToList();

                var builder = new NUnitTestCaseBuilder();

                TestMethod test    = null;
                var        hasTest = false;

                foreach (var provider in _providerNames)
                {
                    var isIgnore = !UserProviders.ContainsKey(provider);

                    foreach (var parameters in GetParameters(provider))
                    {
                        var data = new TestCaseParameters(parameters);

                        test = builder.BuildTestMethod(method, suite, data);

                        foreach (var attr in explic)
                        {
                            attr.ApplyToTest(test);
                        }

                        test.Properties.Set(PropertyNames.Order, GetOrder(method));
                        //test.Properties.Set(PropertyNames.ParallelScope, ParallelScope);
                        test.Properties.Set(PropertyNames.Category, provider);

                        SetName(test, method, provider, false);

                        if (isIgnore)
                        {
                            if (test.RunState != RunState.NotRunnable && test.RunState != RunState.Explicit)
                            {
                                test.RunState = RunState.Ignored;
                            }

                            test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.txt");
                            continue;
                        }

                        hasTest = true;
                        yield return(test);
                    }

#if !NETSTANDARD && !MONO
                    if (!isIgnore && _includeLinqService)
                    {
                        foreach (var paremeters in GetParameters(provider + ".LinqService"))
                        {
                            var data = new TestCaseParameters(paremeters);
                            test = builder.BuildTestMethod(method, suite, data);

                            foreach (var attr in explic)
                            {
                                attr.ApplyToTest(test);
                            }

                            test.Properties.Set(PropertyNames.Order, GetOrder(method));
                            //test.Properties.Set(PropertyNames.ParallelScope, ParallelScope);
                            test.Properties.Set(PropertyNames.Category, provider);

                            SetName(test, method, provider, true);

                            yield return(test);
                        }
                    }
#endif
                }

                if (!hasTest)
                {
                    yield return(test);
                }
            }