コード例 #1
0
 public void CanGenerateFromFiles()
 {
     foreach (var testFile in TestFileHelper.GetTestFiles())
     {
         CanGenerateFromFile(testFile);
     }
 }
コード例 #2
0
 public void CanParseFiles()
 {
     foreach (var testFile in TestFileHelper.GetTestFiles())
     {
         CanParseFile(testFile);
     }
 }
コード例 #3
0
        public void GenerateScenarioExampleTests()
        {
            SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en-US"));

            foreach (var testFile in TestFileHelper.GetTestFiles())
            {
                using (var reader = new StreamReader(testFile))
                {
                    Feature feature = parser.Parse(reader, null);
                    Assert.IsNotNull(feature);

                    Console.WriteLine("Testing {0}", Path.GetFileName(testFile));

                    var           codeDomHelper = new CodeDomHelper(CodeDomProviderLanguage.CSharp);
                    var           sampleTestGeneratorProvider = new SimpleTestGeneratorProvider();
                    var           converter = new SpecFlowUnitTestConverter(sampleTestGeneratorProvider, codeDomHelper, true, true);
                    CodeNamespace code      = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");

                    Assert.IsNotNull(code);

                    // make sure name space is changed
                    Assert.AreEqual(code.Name, SimpleTestGeneratorProvider.DefaultNameSpace);

                    // make sure all method titles are changed correctly
                    List <string> methodTitles = new List <string>();
                    for (int i = 0; i < code.Types[0].Members.Count; i++)
                    {
                        methodTitles.Add(code.Types[0].Members[i].Name);
                    }

                    foreach (var title in sampleTestGeneratorProvider.newTitles)
                    {
                        Assert.IsTrue(methodTitles.Contains(title));
                    }
                }
            }
        }