public static IEnumerable <Feature> GetFeatures(Assembly assembly) { var definitions = new StepDefinitions(assembly); var sources = assembly .GetManifestResourceNames() .Where(name => name.EndsWith(".txt") || name.EndsWith(".feature")); var namespaces = assembly .GetTypes() .Select(t => t.Namespace) .Distinct() .OrderByDescending(s => s.Length); foreach (var source in sources) { var stream = assembly.GetManifestResourceStream(source); var ns = namespaces.FirstOrDefault(s => source.StartsWith(s + ".")); var filename = ns != null?source.Substring(ns.Length + 1) : source; var feature = definitions.GenerateFeature(filename, stream); yield return(feature); } }
public static IEnumerable<Feature> GetFeatures(Assembly assembly) { var definitions = new StepDefinitions(assembly); var sources = assembly .GetManifestResourceNames() .Where(name => name.EndsWith(".txt") || name.EndsWith(".feature")); var namespaces = assembly .GetTypes() .Select(t => t.Namespace) .Distinct() .OrderByDescending(s => s.Length); foreach (var source in sources) { var stream = assembly.GetManifestResourceStream(source); var ns = namespaces.FirstOrDefault(s => source.StartsWith(s + ".")); var filename = ns != null ? source.Substring(ns.Length + 1) : source; var feature = definitions.GenerateFeature(filename, stream); yield return feature; } }
static void Main(string[] args) { var ass = typeof(Program).Assembly; var definitions = new StepDefinitions(ass); var s = ass.GetManifestResourceStream(@"CSharp.Feature.txt"); definitions.Execute(@"..\..\Feature.txt", s); }
public virtual IEnumerable <string> StepNamesOf(Feature Feature, FeatureItem FeatureItem) { if (Feature is InvalidFeature) { return(new List <string>()); } this.Feature = Feature; LoadAssemblies(FeatureItem); return(StepDefinitions.SelectMany(type => type.GetMethods(BindingFlags.Public | BindingFlags.Instance) .Select(method => method.Name.InNaturalLanguage()))); }
private MatchResultItem[] MatchSingleContextResult(Step step, IGherkinDocumentContext context, string stepText = null) { stepText = stepText ?? step.Text; var sdMatches = StepDefinitions.Select(sd => sd.Match(step, context, stepText)).Where(m => m != null).ToArray(); if (!sdMatches.Any()) { return new[] { MatchResultItem.CreateUndefined(step, stepText) } } ; sdMatches = HandleDataTableOverloads(step, sdMatches); sdMatches = HandleDocStringOverloads(step, sdMatches); sdMatches = HandleArgumentlessOverloads(step, sdMatches); sdMatches = HandleScopeOverloads(sdMatches); if (sdMatches.Length == 1) { return new[] { sdMatches[0] } } ; return(sdMatches.Select(mi => mi.CloneToAmbiguousItem()).ToArray()); }
protected FeatureFixture(string source) { _source = source; _assembly = typeof(FeatureFixture).Assembly; _definitions = new StepDefinitions(_assembly); }
public void should_keep_inheritance() { StepDefinitions.ShouldContain(": BaseClass"); }
public void should_keep_defined_content() { StepDefinitions.ShouldContain("var thing = FeatureName"); }
public void should_change_the_class_name() { StepDefinitions.ShouldContain("public partial class Name"); StepDefinitions.ShouldNotContain("public partial class FeatureName"); }
public void should_change_the_namespace() { StepDefinitions.ShouldContain("namespace NewFeatures"); }
public void should_generate_the_StepDefinitions_class() { StepDefinitions.ShouldContain("public partial class Name"); }
public void should_generate_the_StepDefinitions_namespace() { StepDefinitions.ShouldContain("namespace Features"); }
public FeatureFixture(string source) { _source = source; _assembly = typeof(FeatureFixture).Assembly; _definitions = new StepDefinitions(_assembly); }