private void AddSymbolTestCases(NUnitTestFixture fixture, AutoTestSettings testSettings)
        {
            var strategyTest = (StrategyTest)Reflect.Construct(userFixtureType, new object[] { testSettings });

            foreach (var symbol in strategyTest.GetSymbols())
            {
                var paramaterizedTest = new ParameterizedMethodSuite(symbol.Symbol);
                fixture.Add(paramaterizedTest);
                var parms = new ParameterSet();
                parms.Arguments = new object[] { symbol };
                var methods = strategyTest.GetType().GetMethods();
                foreach (var method in methods)
                {
                    var parameters = method.GetParameters();
                    if (!method.IsSpecialName && method.IsPublic && parameters.Length == 1 && parameters[0].ParameterType == typeof(SymbolInfo))
                    {
                        var testCase = NUnitTestCaseBuilder.BuildSingleTestMethod(method, parms);
                        testCase.TestName.Name     = method.Name;
                        testCase.TestName.FullName = fixture.Parent.Parent.TestName.Name + "." +
                                                     fixture.Parent.TestName.Name + "." +
                                                     fixture.TestName.Name + "." +
                                                     symbol + "." +
                                                     method.Name;
                        paramaterizedTest.Add(testCase);
                    }
                }
            }
        }
        public new IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            var asyncTest = method.GetCustomAttributes <AsyncTestAttribute>(true).FirstOrDefault();

            if (asyncTest == null)
            {
                var ret = new TestMethod(method, suite);

                ret.RunState = RunState.NotRunnable;
                ret.Properties.Set("_SKIPREASON", "Method marked with AsyncTestCaseSource must have AsyncTest also applied");

                yield return(ret);

                yield break;
            }

            var tests   = base.BuildFrom(method, suite);
            var builder = new NUnitTestCaseBuilder();

            foreach (var m in tests)
            {
                m.parms.HasExpectedResult = true;
                var newMethod = builder.BuildTestMethod(new EnumeratorTaskWrapper(m.Method, asyncTest.Timeout), suite, m.parms);
                m.parms.HasExpectedResult = false;
                yield return(newMethod);
            }
        }
        /// <summary>
        /// Builds a single test from the specified method and context.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            TestMethod test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForTestCase(method));

#if PLATFORM_DETECTION
            if (IncludePlatform != null || ExcludePlatform != null)
            {
                if (test.RunState == RunState.NotRunnable || test.RunState == RunState.Ignored)
                {
                    yield return(test);

                    yield break;
                }

                var platformHelper = new PlatformHelper();

                if (!platformHelper.IsPlatformSupported(this))
                {
                    test.RunState = RunState.Skipped;
                    test.Properties.Add(PropertyNames.SkipReason, platformHelper.Reason);
                }
            }
#endif

            yield return(test);
        }
        private void AddStrategyTestCases(NUnitTestFixture fixture, AutoTestSettings testSettings)
        {
            var strategyTest = (StrategyTest)Reflect.Construct(userFixtureType, new object[] { testSettings });

            foreach (var modelName in strategyTest.GetModelNames())
            {
                var paramaterizedTest = new ParameterizedMethodSuite(modelName);
                fixture.Add(paramaterizedTest);
                var parms = new ParameterSet();
                parms.Arguments = new object[] { modelName };
                var methods = strategyTest.GetType().GetMethods();
                foreach (var method in methods)
                {
                    var parameters = method.GetParameters();
                    if (!method.IsSpecialName && method.IsPublic && parameters.Length == 1 && parameters[0].ParameterType == typeof(string))
                    {
                        if (CheckIgnoreMethod(testSettings.IgnoreTests, method.Name))
                        {
                            continue;
                        }
                        var testCase = NUnitTestCaseBuilder.BuildSingleTestMethod(method, parms);
                        testCase.TestName.Name     = method.Name;
                        testCase.TestName.FullName = fixture.Parent.Parent.TestName.Name + "." +
                                                     fixture.Parent.TestName.Name + "." +
                                                     fixture.TestName.Name + "." +
                                                     modelName + "." +
                                                     method.Name;
                        paramaterizedTest.Add(testCase);
                    }
                }
            }
        }
Exemple #5
0
        public new IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            var asyncTest = method.GetCustomAttributes <AsyncTestAttribute>(true).FirstOrDefault();

            if (asyncTest == null)
            {
                var ret = new TestMethod(method, suite);

                ret.RunState = RunState.NotRunnable;
                ret.Properties.Set("_SKIPREASON", "Method marked with AsyncTestCase must have AsyncTest also applied");

                yield return(ret);

                yield break;
            }

            var baseParameters = BaseGetParametersForTestCase(method);
            var builder        = new NUnitTestCaseBuilder();

            baseParameters.HasExpectedResult = true;
            var newMethod = builder.BuildTestMethod(new EnumeratorTaskWrapper(method, asyncTest.Timeout), suite, baseParameters);

            // Unity takes arguments for test method from OriginalArguments (incorrect) instead of Arguments (correct)
            // We recreate TestCaseParameters, so Arguments from baseParameters become OriginalArguments in newMethod.params
            newMethod.parms = new TestCaseParameters(baseParameters);
            newMethod.parms.HasExpectedResult = false;
            yield return(newMethod);
        }
Exemple #6
0
        public ExcelTestCaseSourceAttribute(string filePath, string sheetName, Type dataType)
        {
            FilePath  = filePath;
            SheetName = sheetName;
            DataType  = dataType;

            _builder = new NUnitTestCaseBuilder();
        }
Exemple #7
0
        public TestMethod BuildFrom(IMethodInfo method, Test suite)
        {
            var builder    = new NUnitTestCaseBuilder();
            var testMethod = builder.BuildTestMethod(method, suite, null);

            testMethod.Name = method.TypeInfo.Name;
            return(testMethod);
        }
Exemple #8
0
 /// <summary>
 /// the struct method for NunitCommon Class
 /// </summary>
 public NUnitOperate()
 {
     // initialize a NUnitTestCaseBuilder instance
     TestBuilder = new NUnitTestCaseBuilder();
     // initialize a TestCaseParameterProvider instance
     ParamProvider = new TestCaseParameterProvider();
     // initialize a TestCaseSourceProvider instance
     SourceProvider = new TestCaseSourceProvider();
     // initialize a InlineDataPointProvider instance
     dataPointProviders = new InlineDataPointProvider();
 }
Exemple #9
0
        Test BuildTestCase(MethodInfo method, TestSuite suite)
        {
            var test = NUnitTestCaseBuilder.BuildParameterizedMethodSuite(method, suite);

            if (test.TestCount == 0)
            {
                test = NUnitTestCaseBuilder.BuildSingleTestMethod(method, suite, null);
            }
            test.TestName.FullName = suite.TestName.FullName + "." + test.TestName.Name;
            return(test);
        }
Exemple #10
0
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            if (!method.TypeInfo.Type.IsSubclassOf(typeof(Spec)))
            {
                throw new InvalidOperationException($"Only classes inheriting from {nameof(Spec)} can be marked with {nameof(SpecTestCaseSourceAttribute)}");
            }

            var instance = (Spec)method.TypeInfo.Construct(new object[0]);
            var builder  = new NUnitTestCaseBuilder();

            return(instance.TestCases.Select(data => builder.BuildTestMethod(method, suite, new TestCaseParameters(data))));
        }
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, global::NUnit.Framework.Internal.Test suite)
        {
            var builder = new NUnitTestCaseBuilder();

            foreach (var sourceFilePath in Directory.EnumerateFiles(Path, SearchPattern, SearchOption))
            {
                yield return(builder.BuildTestMethod(
                                 method,
                                 suite,
                                 new TestCaseParameters(new object[] { new AnnotatedSourceFile(sourceFilePath) })));
            }
        }
Exemple #12
0
        IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite, IScenario scenario)
        {
            var builder            = new NUnitTestCaseBuilder();
            var resolvedParameters = method.GetParameters()
                                     .Select(p => scenario.DiContainer.TryResolve(p.ParameterType))
                                     .ToArray();

            var tcParams   = new TestCaseParameters(resolvedParameters);
            var testMethod = builder.BuildTestMethod(method, suite, tcParams);

            testMethod.Properties.Add(ScenarioAdapter.ScreenplayScenarioKey, scenario);

            return(new[] { testMethod });
        }
        /// <summary>
        /// Construct one or more TestMethods from a given MethodInfo,
        /// using available parameter data.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        /// <returns>One or more TestMethods</returns>
        public IEnumerable <TestMethod> BuildFrom(MethodInfo method, Test suite)
        {
            TestMethod test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForTestCase(method));

#if !PORTABLE
            if (test.RunState != RunState.NotRunnable &&
                test.RunState != RunState.Ignored &&
                !_platformHelper.IsPlatformSupported(this))
            {
                test.RunState = RunState.Skipped;
                test.Properties.Add(PropertyNames.SkipReason, _platformHelper.Reason);
            }
#endif

            return(new [] { test });
        }
Exemple #14
0
            public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
            {
                var builder = new NUnitTestCaseBuilder();

                TestMethod test    = null;
                var        hasTest = false;

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

                    var data = new TestCaseParameters(new object[] { provider });

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

                    test.Properties.Set(PropertyNames.Category, provider);
                    SetName(test, method, provider, false);

                    if (isIgnore)
                    {
                        test.RunState = RunState.Ignored;
                        test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.txt");
                        continue;
                    }

                    hasTest = true;

                    yield return(test);

                    if (_includeLinqService)
                    {
                        data = new TestCaseParameters(new object[] { provider + ".LinqService" });
                        test = builder.BuildTestMethod(method, suite, data);

                        test.Properties.Set(PropertyNames.Category, provider);
                        SetName(test, method, provider, true);

                        yield return(test);
                    }
                }

                if (!hasTest)
                {
                    yield return(test);
                }
            }
Exemple #15
0
        /// <summary>
        /// Construct one or more TestMethods from a given MethodInfo,
        /// using available parameter data.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        /// <returns>One or more TestMethods</returns>
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            TestMethod test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForTestCase(method));

#if !NETSTANDARD1_3 && !NETSTANDARD1_6
            if (test.RunState != RunState.NotRunnable &&
                test.RunState != RunState.Ignored)
            {
                PlatformHelper platformHelper = new PlatformHelper();

                if (!platformHelper.IsPlatformSupported(this))
                {
                    test.RunState = RunState.Skipped;
                    test.Properties.Add(PropertyNames.SkipReason, platformHelper.Reason);
                }
            }
#endif

            yield return(test);
        }
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            InheritAttributes(method);

            var arguments = new List <object>();

            foreach (var parameter in method.MethodInfo.GetParameters())
            {
                var argument = Resolver.GetService(method, parameter.ParameterType);
                if (argument != null)
                {
                    arguments.Add(argument);
                }
            }

            var testMethod = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, new TestCaseParameters(arguments.ToArray()));

            CheckApplyExecuteInSetup(testMethod);

            yield return(testMethod);
        }
Exemple #17
0
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test?suite)
        {
            TestMethod test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForTestCase(method));

            if (_untilDate.HasValue)
            {
                if (_untilDate > DateTimeOffset.UtcNow)
                {
                    test.RunState = RunState.Ignored;
                    string reason = string.Format("Ignoring until {0}. {1}", _untilDate.Value.ToString("u"), IgnoreReason);
                    test.Properties.Set(PropertyNames.SkipReason, reason);
                }
                else
                {
                    test.RunState = _originalRunState;
                }
            }

            if (IncludePlatform != null || ExcludePlatform != null)
            {
                if (test.RunState == RunState.NotRunnable || test.RunState == RunState.Ignored)
                {
                    yield return(test);

                    yield break;
                }

                var platformHelper = new PlatformHelper();

                if (!platformHelper.IsPlatformSupported(this))
                {
                    test.RunState = RunState.Skipped;
                    test.Properties.Add(PropertyNames.SkipReason, platformHelper.Reason);
                }
            }

            yield return(test);
        }
Exemple #18
0
        TestMethod ISimpleTestBuilder.BuildFrom(IMethodInfo method, Test suite)
        {
            var wrapperMethod = new EnumeratorTaskWrapper(method, Timeout);

            // Set HasExpectedResult=true so call to BuildTestMethod will succeed
            var parms = new TestCaseParameters()
            {
                HasExpectedResult = true
            };
            var ret = new NUnitTestCaseBuilder().BuildTestMethod(wrapperMethod, suite, parms);

            // Set HasExpectedResult=false so it won't fail later because expected result is not same as actual
            ret.parms.HasExpectedResult = false;

            // check return type
            if (!typeof(IPandaTask).IsAssignableFrom(method.ReturnType.Type) && !typeof(Task).IsAssignableFrom(method.ReturnType.Type))
            {
                ret.RunState = RunState.NotRunnable;
                ret.Properties.Set("_SKIPREASON", "Method marked with AsyncTest must return either IPandaTask or System.Threading.Task");
            }

            return(ret);
        }
        /// <summary>
        ///     Construct one or more TestMethods from a given MethodInfo,
        ///     using available parameter data.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        /// <returns>One or more TestMethods</returns>
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            var test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, this.GetParametersForMethod(method));

            yield return(test);
        }
Exemple #20
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);
                }
            }
Exemple #21
0
            public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
            {
                var builder = new NUnitTestCaseBuilder();

                yield return(builder.BuildTestMethod(method, suite, new TestCaseParameters(new object[] { "ArgA", "ArgB" })));
            }
Exemple #22
0
            public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
            {
                var tests = UserProviders.Contains(_providerName) ?
                            new[]
                {
                    new TypeTestData("bigintDataType", 0, (n, t, c) => t.TestTypeEx <long?>             (c, n, DataType.Int64), 1000000),
                    new TypeTestData("bigintDataType", 1, (n, t, c) => t.TestTypeEx <long?>             (c, n, DataType.Int64), 1000000),
                    new TypeTestData("numericDataType", (n, t, c) => t.TestTypeEx <decimal?>          (c, n, DataType.Decimal), 9999999m),
                    new TypeTestData("smallintDataType", (n, t, c) => t.TestTypeEx <short?>            (c, n, DataType.Int16), 25555),
                    new TypeTestData("intDataType", (n, t, c) => t.TestTypeEx <int?>              (c, n, DataType.Int32), 7777777),
//						new TypeTestData("moneyDataType",       (n,t,c) => t.TestTypeEx<decimal?>          (c, n, DataType.Money),   100000m),
                    new TypeTestData("doubleDataType", (n, t, c) => t.TestTypeEx <double?>           (c, n, DataType.Double), 20.31d),
                    new TypeTestData("realDataType", (n, t, c) => t.TestTypeEx <float?>            (c, n, DataType.Single), 16.2f),

#if NPG2
                    new TypeTestData("timestampDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeStamp?>  (c, n), new NpgsqlTimeStamp(2012, 12, 12, 12, 12, 12)),
                    new TypeTestData("timestampTZDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeStampTZ?>(c, n), new NpgsqlTimeStampTZ(2012, 12, 12, 11, 12, 12, new NpgsqlTimeZone(-5, 0))),
                    new TypeTestData("timeDataType", (n, t, c) => t.TestTypeEx <NpgsqlTime?>       (c, n), new NpgsqlTime(12, 12, 12)),
                    new TypeTestData("timeTZDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeTZ?>     (c, n), new NpgsqlTimeTZ(12, 12, 12)),
                    new TypeTestData("intervalDataType", (n, t, c) => t.TestTypeEx <NpgsqlInterval?>   (c, n), new NpgsqlInterval(1, 3, 5, 20)),
                    new TypeTestData("bitDataType", (n, t, c) => t.TestTypeEx <BitString?>        (c, n), new BitString(new[] { true, false, true })),
                    new TypeTestData("macaddrDataType", (n, t, c) => t.TestTypeEx <NpgsqlMacAddress?> (c, n), new NpgsqlMacAddress("01:02:03:04:05:06")),
#else
//						new TypeTestData("timestampDataType",   (n,t,c) => t.TestTypeEx<NpgsqlTimeStamp?>  (c, n),                       new NpgsqlTimeStamp(2012, 12, 12, 12, 12, 12)),
//						new TypeTestData("timestampTZDataType", (n,t,c) => t.TestTypeEx<NpgsqlTimeStampTZ?>(c, n),                       new NpgsqlTimeStampTZ(2012, 12, 12, 11, 12, 12, new NpgsqlTimeZone(-5, 0))),
                    new TypeTestData("timeDataType", (n, t, c) => t.TestTypeEx <TimeSpan?>         (c, n), new TimeSpan(12, 12, 12)),
//						new TypeTestData("timeTZDataType",      (n,t,c) => t.TestTypeEx<NpgsqlTimeTZ?>     (c, n),                       new NpgsqlTimeTZ(12, 12, 12)),
//						new TypeTestData("intervalDataType",    (n,t,c) => t.TestTypeEx<TimeSpan?>         (c, n),                       new TimeSpan(1, 3, 5, 20)),
                    new TypeTestData("bitDataType", (n, t, c) => t.TestTypeEx <BitArray>          (c, n), new BitArray(new[] { true, false, true })),
                    new TypeTestData("varBitDataType", (n, t, c) => t.TestTypeEx <BitArray>          (c, n), new BitArray(new[] { true, false, true, true })),
                    new TypeTestData("macaddrDataType", (n, t, c) => t.TestTypeEx <PhysicalAddress>   (c, n, skipDefaultNull: true), new PhysicalAddress(new byte[] { 1, 2, 3, 4, 5, 6 })),
#endif

                    new TypeTestData("timestampDataType", (n, t, c) => t.TestTypeEx <DateTime?>         (c, n, DataType.DateTime2), new DateTime(2012, 12, 12, 12, 12, 12)),
                    new TypeTestData("timestampTZDataType", (n, t, c) => t.TestTypeEx <DateTimeOffset?>   (c, n, DataType.DateTimeOffset), new DateTimeOffset(2012, 12, 12, 11, 12, 12, new TimeSpan(-5, 0, 0))),
                    new TypeTestData("dateDataType", 0, (n, t, c) => t.TestTypeEx <NpgsqlDate?>       (c, n, skipDefaultNull: true), new NpgsqlDate(2012, 12, 12)),
                    new TypeTestData("dateDataType", 1, (n, t, c) => t.TestTypeEx <DateTime?>         (c, n, DataType.Date), new DateTime(2012, 12, 12)),

                    new TypeTestData("charDataType", 0, (n, t, c) => t.TestTypeEx <char?>             (c, n, DataType.Char), '1'),
                    new TypeTestData("charDataType", 1, (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.Char, skipDefaultNull: true), "1"),
                    new TypeTestData("charDataType", 2, (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.NChar, skipDefaultNull: true), "1"),
                    new TypeTestData("varcharDataType", 0, (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.VarChar, skipDefaultNull: true), "234"),
                    new TypeTestData("varcharDataType", 1, (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.NVarChar, skipDefaultNull: true), "234"),
                    new TypeTestData("textDataType", (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.Text, skipDefaultNull: true), "567"),

                    new TypeTestData("binaryDataType", 0, (n, t, c) => t.TestTypeEx <byte[]>            (c, n, DataType.Binary), new byte[] { 42 }),
                    new TypeTestData("binaryDataType", 1, (n, t, c) => t.TestTypeEx <byte[]>            (c, n, DataType.VarBinary), new byte[] { 42 }),
                    new TypeTestData("binaryDataType", 2, (n, t, c) => t.TestTypeEx <Binary>            (c, n, DataType.VarBinary).ToArray(), new byte[] { 42 }),

                    new TypeTestData("uuidDataType", (n, t, c) => t.TestTypeEx <Guid?>             (c, n, DataType.Guid), new Guid("6F9619FF-8B86-D011-B42D-00C04FC964FF")),
                    new TypeTestData("booleanDataType", (n, t, c) => t.TestTypeEx <bool?>             (c, n, DataType.Boolean), true),
//						new TypeTestData("colorDataType",       (n,t,c) => t.TestTypeEx<string>            (c, n, skipDefaultNull:true, skipDefault:true,skipUndefined:true), "Green"),

                    new TypeTestData("pointDataType", (n, t, c) => t.TestTypeEx <NpgsqlPoint?>      (c, n, skipNull: true, skipNotNull: true), new NpgsqlPoint(1, 2)),
                    new TypeTestData("lsegDataType", (n, t, c) => t.TestTypeEx <NpgsqlLSeg?>       (c, n, skipDefaultNull: true), new NpgsqlLSeg(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))),
                    new TypeTestData("boxDataType", (n, t, c) => t.TestTypeEx <NpgsqlBox?>        (c, n, skipDefaultNull: true).ToString(), new NpgsqlBox(new NpgsqlPoint(3, 4), new NpgsqlPoint(1, 2)).ToString()),
#if !NPGSQL226
                    new TypeTestData("pathDataType", (n, t, c) => t.TestTypeEx <NpgsqlPath?>       (c, n, skipDefaultNull: true), new NpgsqlPath(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))),
                    new TypeTestData("polygonDataType", (n, t, c) => t.TestTypeEx <NpgsqlPolygon?>    (c, n, skipNull: true, skipNotNull: true), new NpgsqlPolygon(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))),
#endif
                    new TypeTestData("circleDataType", (n, t, c) => t.TestTypeEx <NpgsqlCircle?>     (c, n, skipDefaultNull: true), new NpgsqlCircle(new NpgsqlPoint(1, 2), 3)),

                    new TypeTestData("inetDataType", (n, t, c) => t.TestTypeEx <NpgsqlInet?>       (c, n, skipDefaultNull: true), new NpgsqlInet(new IPAddress(new byte[] { 192, 168, 1, 1 }))),

                    new TypeTestData("xmlDataType", 0, (n, t, c) => t.TestTypeEx <string>            (c, n, DataType.Xml, skipNull: true, skipNotNull: true),
                                     "<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>"),
                    new TypeTestData("xmlDataType", 1, (n, t, c) => t.TestTypeEx <XDocument>         (c, n, DataType.Xml, skipNull: true, skipNotNull: true).ToString(),
                                     XDocument.Parse("<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>").ToString()),
                    new TypeTestData("xmlDataType", 2, (n, t, c) => t.TestTypeEx <XmlDocument>       (c, n, DataType.Xml, skipNull: true, skipNotNull: true).InnerXml,
                                     ConvertTo <XmlDocument> .From("<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>").InnerXml),
                }
                                        :
                new[]
                {
                    new TypeTestData("ignore", (n, t, c) => t.TestTypeEx <long?>(c, n, DataType.Int64), 1000000)
                };

                var builder = new NUnitTestCaseBuilder();

                var data = tests.Select(t => new TestCaseParameters(new object[] { t.Name, t.ID, t, _providerName }));

                foreach (var item in data)
                {
                    var test = builder.BuildTestMethod(method, suite, item);

                    test.Properties.Set(PropertyNames.Category, _providerName);

                    if (!UserProviders.Contains(_providerName))
                    {
                        test.RunState = RunState.Ignored;
                        test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See DataProviders.json");
                    }

                    yield return(test);
                }
            }
 public void Setup()
 {
     _builder    = new NUnitTestCaseBuilder();
     _testObject = new AsyncRealFixture();
 }
 public void Setup()
 {
     _sut = new NUnitTestCaseBuilder();
 }
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            // pick attributes that we want to apply to each configuration-specific test case
            var testAttributes = method.GetCustomAttributes <ExplicitAttribute>(true)
                                 .Cast <IApplyToTest>()
                                 .Union(method.TypeInfo.GetCustomAttributes <ExplicitAttribute>(true))
#if !NETSTANDARD1_6
                                 .Union(method.TypeInfo.Assembly.GetCustomAttributes(true).OfType <ExplicitAttribute>())
#endif
                                 .Union(method.GetCustomAttributes <IgnoreAttribute>(true))
                                 .Union(method.TypeInfo.GetCustomAttributes <IgnoreAttribute>(true))
#if !NETSTANDARD1_6
                                 .Union(method.TypeInfo.Assembly.GetCustomAttributes(true).OfType <IgnoreAttribute>())
#endif
                                 .Union(method.GetCustomAttributes <ActiveIssueAttribute>(true))
                                 .Union(method.TypeInfo.GetCustomAttributes <ActiveIssueAttribute>(true))
                                 .ToList();

            var maxTime = method.GetCustomAttributes <MaxTimeAttribute>(true).FirstOrDefault();

            testAttributes.Add(maxTime ?? new MaxTimeAttribute(10000));

//#if !NETSTANDARD1_6
//				var timeout = method.GetCustomAttributes<TimeoutAttribute>(true).FirstOrDefault();
//				explic.Add(timeout ?? new TimeoutAttribute(10000));
//#endif

            var builder = new NUnitTestCaseBuilder();

            TestMethod test    = null;
            var        hasTest = false;

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

                var caseNumber = 0;
                foreach (var parameters in GetParameters(provider))
                {
                    var data = new TestCaseParameters(parameters.Item1);

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

                    test.Properties.Set(ProviderProperty, provider);
                    test.Properties.Set(ConfigurationProperty, provider);
                    test.Properties.Set(IsLinqServiceProperty, false);

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

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

                    test.Properties.Add(PropertyNames.Category, provider);

                    SetName(test, method, provider, false, caseNumber++, parameters.Item2);

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

#if !APPVEYOR && !TRAVIS
                        if (!test.Properties.ContainsKey(PropertyNames.SkipReason))
                        {
                            test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.json or DataProviders.json");
                        }
#endif
                        continue;
                    }

                    if (test.RunState != RunState.Runnable)
                    {
                        test.Properties.Add(PropertyNames.Category, "Ignored");
                    }

                    hasTest = true;
                    yield return(test);
                }

#if !NETSTANDARD1_6 && !NETSTANDARD2_0 && !MONO
                if (!isIgnore && _includeLinqService)
                {
                    var linqCaseNumber = 0;
                    var providerBase   = provider;
                    foreach (var parameters in GetParameters(provider + ".LinqService"))
                    {
                        var data = new TestCaseParameters(parameters.Item1);
                        test = builder.BuildTestMethod(method, suite, data);

                        test.Properties.Set(ProviderProperty, providerBase);
                        test.Properties.Set(ConfigurationProperty, provider);
                        test.Properties.Set(IsLinqServiceProperty, true);

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

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

                        SetName(test, method, provider, true, linqCaseNumber++, parameters.Item2);

                        yield return(test);
                    }
                }
#endif
            }

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