• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SyntaxElements.Feature类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TechTalk.SpecFlow.Parser.SyntaxElements.Feature的典型用法代码示例。如果您正苦于以下问题:C# Feature类的具体用法?C# Feature怎么用?C# Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Feature类属于TechTalk.SpecFlow.Parser.SyntaxElements命名空间,在下文中一共展示了Feature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CompareWithExpectedResult

        private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
        {
            string expected = TestFileHelper.ReadFile(expectedResultFileName).Replace("\r", "");
            string got = SerializeFeature(feature).Replace("\r", "");

            Assert.AreEqual(expected, got);
        }
开发者ID:roffster,项目名称:SpecFlow,代码行数:7,代码来源:SuccessfulParsingTest.cs


示例2: CompileAndCreateTest

        private object CompileAndCreateTest(string fileName, Feature feature)
        {
            string className = Path.GetFileNameWithoutExtension(fileName);
            const string targetNamespace = "Target.Namespace";
            // the row test generation has to be set to false, because our verifications support the old style test generation only
            SpecFlowUnitTestConverter converter = new SpecFlowUnitTestConverter(CreateUnitTestGeneratorProvider(), new CodeDomHelper(CodeDomProviderLanguage.CSharp), new GeneratorConfiguration { AllowRowTests = false, AllowDebugGeneratedFiles = true }); 
            var codeNamespace = converter.GenerateUnitTestFixture(feature, className, targetNamespace);
            var compileUnit = new CodeCompileUnit();
            compileUnit.Namespaces.Add(codeNamespace);

            Dictionary<string, string> providerOptions = new Dictionary<string, string>();
            providerOptions["CompilerVersion"] = "v3.5";

            CSharpCodeProvider codeProvider = new CSharpCodeProvider(providerOptions);

            CompilerParameters compilerParameters = new CompilerParameters();
            compilerParameters.GenerateInMemory = true;
            compilerParameters.TempFiles.KeepFiles = true;

            compilerParameters.ReferencedAssemblies.Add(
                TestFileHelper.GetAssemblyPath(typeof (GeneratedCodeAttribute))); //System
            compilerParameters.ReferencedAssemblies.Add(
                TestFileHelper.GetAssemblyPath(typeof (TestAttribute))); //NUnit
            compilerParameters.ReferencedAssemblies.Add(
                TestFileHelper.GetAssemblyPath(typeof (ITestRunner))); //TechTalk.SpecFlow

            var results = codeProvider.CompileAssemblyFromDom(compilerParameters, compileUnit);

            if (results.NativeCompilerReturnValue != 0)
                throw new InvalidOperationException("Test cannot be compiled: " + 
                                                    string.Join(Environment.NewLine, results.Errors.Cast<CompilerError>().Select(ce => ce.ToString()).ToArray()));

            Type testType = results.CompiledAssembly.GetType(targetNamespace + "." + className, true);
            return Activator.CreateInstance(testType);
        }
开发者ID:roffster,项目名称:SpecFlow,代码行数:35,代码来源:ExecutionTestBase.cs


示例3: CompareWithExpectedResult

        private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
        {
            string expected = TestFileHelper.ReadFile(expectedResultFileName);
            string got = GenerateCodeFromFeature(feature);

            Assert.AreEqual(expected, got);
        }
开发者ID:nandrew,项目名称:SpecFlow,代码行数:7,代码来源:SuccessfulMbUnitGenerationTest.cs


示例4: MatchPrefix

        public static bool MatchPrefix(this ITagFilterMatcher tagFilterMatcher, string tagFilter, Feature feature)
        {
            if (feature.Tags == null)
                return false;

            return tagFilterMatcher.MatchPrefix(tagFilter, feature.Tags.Select(t => t.Name));
        }
开发者ID:BEllis,项目名称:SpecFlow,代码行数:7,代码来源:ITagFilterMatcher.cs


示例5: GenerateCodeFromFeature

 private void GenerateCodeFromFeature(Feature feature, string fileName)
 {
     using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
     {
         GenerateCodeFromFeature(feature, writer);
     }
 }
开发者ID:nandrew,项目名称:SpecFlow,代码行数:7,代码来源:SuccessfulMbUnitGenerationTest.cs


示例6: SerializeFeature

 private void SerializeFeature(Feature feature, string fileName)
 {
     using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
     {
         SerializeFeature(feature, writer);
     }
 }
开发者ID:Galad,项目名称:SpecFlow,代码行数:7,代码来源:ParserDriver.cs


示例7: Should_UnitTestFeatureGeneratorProvider_create_UnitTestFeatureGenerator_instance

        public void Should_UnitTestFeatureGeneratorProvider_create_UnitTestFeatureGenerator_instance()
        {
            var generatorProvider = CreateUnitTestFeatureGeneratorProvider();
            Feature anyFeature = new Feature();
            var generator = generatorProvider.CreateGenerator(anyFeature);

            generator.Should().BeOfType<UnitTestFeatureGenerator>();
        }
开发者ID:aqueduct,项目名称:SpecflowWithNunitRunner,代码行数:8,代码来源:FeatureGeneratorProviderTests.cs


示例8: Should_UnitTestFeatureGeneratorProvider_create_valid_instance

        public void Should_UnitTestFeatureGeneratorProvider_create_valid_instance()
        {
            var generatorProvider = CreateUnitTestFeatureGeneratorProvider();
            Feature anyFeature = new Feature();
            var generator = generatorProvider.CreateGenerator(anyFeature);

            generator.Should().NotBeNull();
        }
开发者ID:aqueduct,项目名称:SpecflowWithNunitRunner,代码行数:8,代码来源:FeatureGeneratorProviderTests.cs


示例9: SerializeFeature

 private string SerializeFeature(Feature feature)
 {
     using (var writer = new Utf8StringWriter())
     {
         SerializeFeature(feature, writer);
         return writer.ToString();
     }
 }
开发者ID:roffster,项目名称:SpecFlow,代码行数:8,代码来源:SuccessfulParsingTest.cs


示例10: ScenarioOutlineViewModel

        public ScenarioOutlineViewModel(Feature feature, ScenarioOutline scenarioOutline)
            : base(scenarioOutline, feature)
        {
            var bgSteps = feature.Background != null ? feature.Background.Steps.AsEnumerable() : Enumerable.Empty<ScenarioStep>();

            StepTemplates = bgSteps.Concat(scenarioOutline.Steps).Select(x => new StepTemplateViewModel(x)).ToList();

            Examples = scenarioOutline.Examples.ExampleSets.Select(x => new ScenarioOutlineExampleSetViewModel(this, x)).ToList();
        }
开发者ID:robfe,项目名称:SpecShow,代码行数:9,代码来源:ScenarioOutlineViewModel.cs


示例11: ExecuteTests

 protected override void ExecuteTests(object test, Feature feature)
 {
     NUnitTestExecutor.ExecuteNUnitTests(test,
         delegate(Exception exception)
         {
             Assert.IsInstanceOf(typeof(InconclusiveException), exception);
             return true;
         });
 }
开发者ID:roffster,项目名称:SpecFlow,代码行数:9,代码来源:SuccessfulExecutionTest.cs


示例12: Should_create_UnitTestFeatureGenerator_with_default_setup

        public void Should_create_UnitTestFeatureGenerator_with_default_setup()
        {
            var featureGeneratorRegistry = CreateFeatureGeneratorRegistry();

            Feature anyFeature = new Feature();
            var generator = featureGeneratorRegistry.CreateGenerator(anyFeature);

            generator.Should().BeOfType<UnitTestFeatureGenerator>();
        }
开发者ID:Galad,项目名称:SpecFlow,代码行数:9,代码来源:FeatureGeneratorRegistryTests.cs


示例13: GenerateCodeFromFeature

        private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
        {
            SpecFlowUnitTestConverter converter = FactoryMethods.CreateUnitTestConverter(new NUnitTestConverter());
            var codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");

            CSharpCodeProvider codeProvider = new CSharpCodeProvider();
            CodeGeneratorOptions options = new CodeGeneratorOptions();
            codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
        }
开发者ID:roffster,项目名称:SpecFlow,代码行数:9,代码来源:SuccessfulGenerationTest.cs


示例14: GetTagValue

        public static bool GetTagValue(this ITagFilterMatcher tagFilterMatcher, string tagFilter, Feature feature, out string value)
        {
            if (feature.Tags == null)
            {
                value = null;
                return false;
            }

            return tagFilterMatcher.GetTagValue(tagFilter, feature.Tags.Select(t => t.Name), out value);
        }
开发者ID:BEllis,项目名称:SpecFlow,代码行数:10,代码来源:ITagFilterMatcher.cs


示例15: FeatureViewModel

        public FeatureViewModel(Feature feature)
        {
            FeatureNode = feature;
            if (feature.Background != null)
            {
                BackgroundSteps = feature.Background.Steps.Select(x => new StepViewModel(x)).ToList();
            }

            Scenarios = feature.Scenarios.Select(x => x is ScenarioOutline ? (ScenarioViewModelBase)new ScenarioOutlineViewModel(feature, (ScenarioOutline) x) : new ScenarioViewModel(feature, x)).ToList();
        }
开发者ID:robfe,项目名称:SpecShow,代码行数:10,代码来源:FeatureViewModel.cs


示例16: GetResult

 public Feature GetResult()
 {
     var feature = new Feature(
         title,
         tags,
         description,
         background == null ? null : background.GetResult(),
         scenarios.Select(sb => sb.GetResult()).ToArray());
     feature.SourceFile = sourceFilePath;
     return feature;
 }
开发者ID:xerxesb,项目名称:SpecFlow,代码行数:11,代码来源:FeatureBuilder.cs


示例17: GenerateCodeFromFeature

		private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
		{
		    CodeDomHelper codeDomHelper = new CodeDomHelper(CodeDomProviderLanguage.CSharp);
		    XUnitTestGeneratorProvider xUnitTestGeneratorProvider = new XUnitTestGeneratorProvider();
		    SpecFlowUnitTestConverter converter = FactoryMethods.CreateUnitTestConverter(xUnitTestGeneratorProvider);
			var codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");

			CSharpCodeProvider codeProvider = new CSharpCodeProvider();
			CodeGeneratorOptions options = new CodeGeneratorOptions();
			codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
		}
开发者ID:roffster,项目名称:SpecFlow,代码行数:11,代码来源:SuccessfulXUnitGenerationTest.cs


示例18: GetPlainText

        private static string GetPlainText(string fileName, Scenario scenario, Feature feature)
        {
            var lines = File.ReadAllLines(fileName);

            var nextScenario = feature.Scenarios.SkipWhile(s => s != scenario).Skip(1).FirstOrDefault();

            int startLine = scenario.FilePosition.Line;
            int endLine = nextScenario == null ? lines.Count() : nextScenario.FilePosition.Line - 1;

            return string.Join(Environment.NewLine, lines.Skip(startLine - 1).Take(endLine - startLine + 1)).Replace("\t", "  ");
        }
开发者ID:gasparnagy,项目名称:CodeExample-SpecFlow-LivingHelp,代码行数:11,代码来源:ScenarioLoader.cs


示例19: GenerateUnitTestFixture

    /// <summary>
    /// Generates the unit test fixture.
    /// </summary>
    /// <param name="feature">The feature.</param>
    /// <param name="testClassName">Name of the test class.</param>
    /// <param name="targetNamespace">The target namespace.</param>
    /// <returns>Instance of CodeNamespace.</returns>
    public CodeNamespace GenerateUnitTestFixture(Feature feature, string testClassName, string targetNamespace)
    {
      CodeNamespace result = this.baseFeatureGenerator.GenerateUnitTestFixture(feature, testClassName, targetNamespace);

      if (this.IsLiveTest(feature))
      {
        this.DecorateStaticMethods(result);
        this.DecorateFixtureClasses(result);
      }

      return result;
    }
开发者ID:sergeyshushlyapin,项目名称:Sitecore.LiveTesting,代码行数:19,代码来源:LiveTestFeatureGenerator.cs


示例20: GetFeatureText

        public string GetFeatureText(Feature feature, CultureInfo defaultLanguage = null)
        {
            defaultLanguage = defaultLanguage ?? new CultureInfo("en-US");
            var dialectServices = new GherkinDialectServices(defaultLanguage);
            var dialect = dialectServices.GetGherkinDialect(feature);

            var result = new StringBuilder();

            AppendHeader(defaultLanguage, dialect, result);

            AppendTags(result, feature.Tags);
            AppendFeatureLine(feature, result);
            AppendLine(result);

            if (feature.Background != null)
            {
                AppendBackgroundLine(feature.Background, result);
                AppendSteps(feature.Background.Steps, result);
                AppendLine(result);
            }

            foreach (var scenario in feature.Scenarios)
            {
                var outline = scenario as ScenarioOutline;
                bool isOutline = outline != null;

                AppendTags(result, scenario.Tags);
                AppendScenarioLine(result, scenario, dialect, isOutline);

                AppendSteps(scenario.Steps, result);

                AppendLine(result);

                if (isOutline)
                {
                    foreach (var exampleSet in outline.Examples.ExampleSets)
                    {
                        AppendTags(result, exampleSet.Tags);
                        AppendExampleSetLine(result, dialect, exampleSet);
                        AppendTable(result, exampleSet.Table, indent);
                        AppendLine(result);
                    }
                }

                AppendLine(result);
            }

            return result.ToString();
        }
开发者ID:chebizarro,项目名称:berp,代码行数:49,代码来源:FeatureFormatter.cs



注:本文中的TechTalk.SpecFlow.Parser.SyntaxElements.Feature类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Kauwa.Session类代码示例发布时间:2022-05-26
下一篇:
C# Gherkin.GherkinBufferSpan类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap