Exemplo n.º 1
0
        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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        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);
                    }
                }
            }
        }