/// <summary>
 /// Indicates whether the Spock search options are valid. Must have either a file path, a directory value,
 /// or an introspection target.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>
 /// <c>true</c> to indicate that the Spock options are valid; otherwise<c>false</c>, meaning
 /// that neither the <see cref="ISpockOptions.SourceFilePath"/>, the <see cref="ISpockOptions.Directory"/>,
 /// or the <see cref="ISpockOptions.IntrospectionTarget"/>
 /// value has been supplied.
 /// </returns>
 public static bool SearchValid(this ISpockOptions options)
 {
     return(!string.IsNullOrEmpty(options.Directory) ||
            !string.IsNullOrEmpty(options.SourceFilePath) ||
            !string.IsNullOrEmpty(options.IntrospectionTarget) ||
            !string.IsNullOrEmpty(options.I18N));
 }
Пример #2
0
        public FixtureBuilder(IGherkinFeature gherkin, ISpockOptions options)
        {
            this.gherkin           = gherkin;
            this.options           = options;
            this.fixtureInvariants = new FixtureInvariants(gherkin, options);

            var summary = new List <string>
            {
                "Feature Id: " + this.fixtureInvariants.FeatureId,
                gherkin.Name,
                gherkin.Description
            };

            if (gherkin.Background != null)
            {
                summary.AddRange(gherkin.Background.Gherkin);
            }

            var disabled = gherkin.Comments.DisabledScenarios("<item>", "</item>").ToArray();

            if (disabled.Any())
            {
                const string header =
                    "The following Scenario Ids (Test Step Id's) have been disabled from this fixture. Please review " +
                    "the original test cases XML file to see if the test scenario was valid, and if " +
                    "so, update the Gherkin .feature file to reflect the test case. Then regenerate " +
                    "this test fixture to include the new scenario.";

                var builder = new StringBuilder();
                builder.Append(header);
                builder.Append("<list type=\"bullet\">");
                foreach (var d in disabled)
                {
                    builder.Append(d);
                }

                builder.Append("</list>");
                summary.Add(builder.ToString());
            }

            this.comments.AddRange(CodeGeneration.ToXmlSummary(summary.ToArray(), false));
            this.comments.AddRange(CodeGeneration.ToXmlRemarks(gherkin.Gherkin, new[] { "example", "code language=\"none\" title=\"Gherkin\"" }));
            this.feature = FixtureStep.Create(GherkinKeyword.Feature, gherkin.Description);
            if (gherkin.Background == null)
            {
                return;
            }

            this.background = new BackgroundBuilder(gherkin.Background).Build();
            this.feature.AddBackground(this.background);
        }
Пример #3
0
        public FixtureInvariants(IGherkinFeature gherkin, ISpockOptions options)
        {
            this.FixtureName = gherkin.Name.ToSafeSyntax();

            this.Namespace = !string.IsNullOrEmpty(options.QualifiedNamespace)
                ? options.QualifiedNamespace
                : gherkin.Namespace;

            var maybe = gherkin.Comments.Find(GherkinIdRef.FeatureId);

            this.FeatureId = maybe.HasValue ? maybe.Value.Value : Guid.NewGuid().ToString();

            this.FilePath = gherkin.SourceFile.Replace(".feature", ".generated.cs");
        }
Пример #4
0
        public FixtureMethodBuilder(IGherkinBlock background, IGherkinScenario scenario, ISpockOptions options, IFixtureInvariants fixtureInvariants)
        {
            if (string.IsNullOrEmpty(scenario.Name))
            {
                throw new GherkinException(
                          GherkinExceptionType.InvalidGherkin,
                          "No value representing the Scenario name found in the Gherkin feature file.");
            }

            this.background        = background;
            this.scenario          = scenario;
            this.options           = options;
            this.fixtureInvariants = fixtureInvariants;
        }
Пример #5
0
        public static ITestFramework For(ISpockOptions options)
        {
            switch (options.TestRunner)
            {
            case TestRunner.NUnit:
                return(new NUnitTestFramework(options));

            case TestRunner.MSTest:
                return(new MSTestFramework(options));

            default:
                return(new XUnitTestFramework(options));
            }
        }
Пример #6
0
 public SpockFixture(
     IGherkinFeature gherkin,
     IFixtureInvariants fixtureInvariants,
     IFixtureStep feature,
     IEnumerable <string> comments,
     IFixtureBackground background,
     IFixtureMethods methods,
     ISpockOptions options)
     : base(options, fixtureInvariants)
 {
     this.gherkin           = gherkin;
     this.FixtureInvariants = fixtureInvariants;
     this.GherkinAttributes = feature;
     this.XmlDocComments    = new SpockCollection <string>(comments);
     this.Background        = background;
     this.FixtureMethods    = methods;
 }
Пример #7
0
        public FixtureMethod(
            IGherkinBlock background,
            IMethods methods,
            IGherkinScenario scenario,
            ISpockOptions options,
            IFixtureInvariants fixtureInvariants)
            : base(options, fixtureInvariants)
        {
            this.background = background;
            this.scenario   = scenario;
            this.Methods    = methods;
            this.Identity   = new MethodIdentity(scenario);

            var methodBuilder = SyntaxScenario.For(scenario);

            this.Signature = methodBuilder.Signature;
            this.TestCases = methodBuilder.TestCases;
        }
Пример #8
0
 public NUnitTestFramework(ISpockOptions options)
     : base(options)
 {
 }
Пример #9
0
 /// <summary>
 /// Creates and returns an object that supports the <see cref="ISpockLexer" /> interface.
 /// </summary>
 /// <param name="options">The Spock options.</param>
 /// <returns>
 /// An that supports the <see cref="ISpockLexer" /> interface.
 /// </returns>
 public static ISpockLexer For(ISpockOptions options)
 {
     return(new SpockLexer(options));
 }
Пример #10
0
 protected SpecificationBase(ISpockOptions options, IFixtureInvariants fixtureInvariants)
 {
     this.Options           = options;
     this.fixtureInvariants = fixtureInvariants;
 }
 /// <summary>
 /// Returns the <see cref="DirectoryInfo"/> object relating to the Spock options value.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>A <see cref="DirectoryInfo"/> object relating to the Spock options value.</returns>
 public static DirectoryInfo DirectoryInfo(this ISpockOptions options)
 {
     return(new DirectoryInfo(options.Directory));
 }
Пример #12
0
 public MSTestFramework(ISpockOptions options)
     : base(options)
 {
 }
 /// <summary>
 /// Determines whether an introspection target has been specified.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns><c>true</c> to indicate that we are to process an introspection target;otherwise <c>false</c>.</returns>
 public static bool IsIntrospectionSpecified(this ISpockOptions options)
 {
     return(!string.IsNullOrEmpty(options.IntrospectionTarget));
 }
 /// <summary>
 /// Sources the specified options.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>The <see cref="FileInfo"/> object that relates to the source file path.</returns>
 public static FileInfo Source(this ISpockOptions options)
 {
     return(new FileInfo(options.SourceFilePath));
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestFramework"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 protected TestFramework(ISpockOptions options)
 {
     this.Options = options;
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpockLexer" /> class.
 /// </summary>
 /// <param name="options">The options.</param>
 public SpockLexer(ISpockOptions options)
 {
     this.options = options;
 }
 /// <summary>
 /// Determines whether a file has been specified in the options, or whether we should
 /// scan a directory for Gherkin .feature files.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns><c>true</c> to indicate that we are to process a single file;otherwise <c>false</c> to scan a directory.</returns>
 public static bool IsFileSpecified(this ISpockOptions options)
 {
     return(!string.IsNullOrEmpty(options.SourceFilePath));
 }