Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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())));
        }
Esempio n. 5
0
        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());
        }
Esempio n. 6
0
 protected FeatureFixture(string source)
 {
     _source = source;
     _assembly = typeof(FeatureFixture).Assembly;
     _definitions = new StepDefinitions(_assembly);
 }
Esempio n. 7
0
 public void should_keep_inheritance()
 {
     StepDefinitions.ShouldContain(": BaseClass");
 }
Esempio n. 8
0
 public void should_keep_defined_content()
 {
     StepDefinitions.ShouldContain("var thing = FeatureName");
 }
Esempio n. 9
0
 public void should_change_the_class_name()
 {
     StepDefinitions.ShouldContain("public partial class Name");
     StepDefinitions.ShouldNotContain("public partial class FeatureName");
 }
Esempio n. 10
0
 public void should_change_the_namespace()
 {
     StepDefinitions.ShouldContain("namespace NewFeatures");
 }
Esempio n. 11
0
 public void should_generate_the_StepDefinitions_class()
 {
     StepDefinitions.ShouldContain("public partial class Name");
 }
Esempio n. 12
0
 public void should_generate_the_StepDefinitions_namespace()
 {
     StepDefinitions.ShouldContain("namespace Features");
 }
Esempio n. 13
0
 public FeatureFixture(string source)
 {
     _source      = source;
     _assembly    = typeof(FeatureFixture).Assembly;
     _definitions = new StepDefinitions(_assembly);
 }