コード例 #1
0
        public void CreateTestClassStructure(string testClassName, SpecFlowDocument document)
        {
            var generatedTypeDeclaration = _codeDomHelper.CreateGeneratedTypeDeclaration(testClassName);

            CodeNamespace.Types.Add(generatedTypeDeclaration);
            GenerationContext = new TestClassGenerationContext(_testGeneratorProvider, document, CodeNamespace, generatedTypeDeclaration, generatedTypeDeclaration.DeclareTestRunnerMember <ITestRunner>("testRunner"), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), generatedTypeDeclaration.CreateMethod(), document.SpecFlowFeature.HasFeatureBackground() ? generatedTypeDeclaration.CreateMethod() : null, _testGeneratorProvider.GetTraits().HasFlag(UnitTestGeneratorTraits.RowTests) && _specFlowConfiguration.AllowRowTests);
        }
コード例 #2
0
        protected int ExpectedNumOfMethodsForFeatureVariants(Scenario scenario, Feature feature = null)
        {
            int numOfMethods = 1;

            if (!_unitTestGeneratorProvider.GetTraits().HasFlag(UnitTestGeneratorTraits.RowTests))
            {
                if (scenario.Tags.Any())
                {
                    var variantTags = scenario.GetTagsByNameStart(SampleFeatureFile.Variant).Count;
                    if (variantTags > 0)
                    {
                        numOfMethods = variantTags;
                    }
                }

                if (scenario is ScenarioOutline so)
                {
                    numOfMethods *= so.GetExamplesTableBody().Count;
                    numOfMethods++;
                }

                return(numOfMethods);
            }
            else
            {
                if (scenario is ScenarioOutline)
                {
                    return(numOfMethods);
                }

                int variantTags = 0;
                if (feature?.HasTags() == true)
                {
                    variantTags += feature.GetTagsByNameStart(SampleFeatureFile.Variant).Count;
                }
                else if (scenario.Tags.Any())
                {
                    variantTags += scenario.GetTagsByNameStart(SampleFeatureFile.Variant).Count;
                }

                if (variantTags > 0)
                {
                    numOfMethods = variantTags;
                }
                return(numOfMethods);
            }
        }
コード例 #3
0
        private TestClassGenerationContext CreateTestClassStructure(CodeNamespace codeNamespace, string testClassName, SpecFlowDocument document)
        {
            var testClass = codeDomHelper.CreateGeneratedTypeDeclaration(testClassName);

            codeNamespace.Types.Add(testClass);

            return(new TestClassGenerationContext(
                       testGeneratorProvider,
                       document,
                       codeNamespace,
                       testClass,
                       DeclareTestRunnerMember(testClass),
                       CreateMethod(testClass),
                       CreateMethod(testClass),
                       CreateMethod(testClass),
                       CreateMethod(testClass),
                       CreateMethod(testClass),
                       CreateMethod(testClass),
                       HasFeatureBackground(document.SpecFlowFeature) ? CreateMethod(testClass) : null,
                       generateRowTests: testGeneratorProvider.GetTraits().HasFlag(UnitTestGeneratorTraits.RowTests) && generatorConfiguration.AllowRowTests));
        }
 public UnitTestGeneratorTraits GetTraits()
 {
     return(_unitTestGeneratorProvider.GetTraits());
 }
 public UnitTestGeneratorTraits GetTraits()
 {
     return(_innerGenerator.GetTraits());
 }