本文整理汇总了C#中TechTalk.SpecFlow.Parser.SyntaxElements.Feature类的典型用法代码示例。如果您正苦于以下问题:C# Feature类的具体用法?C# Feature怎么用?C# Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Feature类属于TechTalk.SpecFlow.Parser.SyntaxElements命名空间,在下文中一共展示了Feature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: CompareWithExpectedResult
private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
{
string expected = TestFileHelper.ReadFile(expectedResultFileName);
string got = GenerateCodeFromFeature(feature);
Assert.AreEqual(expected, got);
}
示例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));
}
示例5: GenerateCodeFromFeature
private void GenerateCodeFromFeature(Feature feature, string fileName)
{
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
GenerateCodeFromFeature(feature, writer);
}
}
示例6: SerializeFeature
private void SerializeFeature(Feature feature, string fileName)
{
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
SerializeFeature(feature, writer);
}
}
示例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>();
}
示例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();
}
示例9: SerializeFeature
private string SerializeFeature(Feature feature)
{
using (var writer = new Utf8StringWriter())
{
SerializeFeature(feature, writer);
return writer.ToString();
}
}
示例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();
}
示例11: ExecuteTests
protected override void ExecuteTests(object test, Feature feature)
{
NUnitTestExecutor.ExecuteNUnitTests(test,
delegate(Exception exception)
{
Assert.IsInstanceOf(typeof(InconclusiveException), exception);
return true;
});
}
示例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>();
}
示例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);
}
示例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);
}
示例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();
}