public async Task ExecuteScenarioAsync(Feature featureInstance, string scenarioName)
        {
            if (featureInstance == null)
            {
                throw new ArgumentNullException(nameof(featureInstance));
            }

            if (string.IsNullOrWhiteSpace(scenarioName))
            {
                throw new ArgumentNullException(nameof(scenarioName));
            }

            var featureClass = FeatureClass.FromFeatureInstance(featureInstance);
            var featureFile  = _featureFileRepository.GetByFilePath(featureClass.FeatureFilePath);

            var gherkinScenario = featureFile.GetScenario(scenarioName);

            if (gherkinScenario == null)
            {
                throw new InvalidOperationException($"Cannot find scenario `{scenarioName}`.");
            }

            var scenario = featureClass.ExtractScenario(gherkinScenario);
            await scenario.ExecuteAsync(new ScenarioOutput(featureInstance.InternalOutput));
        }
        public List <global::Gherkin.Ast.Feature> Discover()
        {
            var allFiles        = _featureFileRepository.GetFeatureFilePaths();
            var referencedFiles = _featureClassInfoRepository.GetFeatureClassesInfo()
                                  .Select(fc => fc.FeatureFilePath)
                                  .ToList();

            var newFiles = allFiles.Where(f => !referencedFiles.Contains(f))
                           .ToList();

            var newFeatures = newFiles.Select(f => _featureFileRepository.GetByFilePath(f))
                              .Select(ff => ff.GherkinDocument.Feature)
                              .ToList();

            return(newFeatures);
        }
        public async Task ExecuteScenarioAsync(Feature featureInstance, string scenarioName)
        {
            if (featureInstance == null)
            {
                throw new System.ArgumentNullException(nameof(featureInstance));
            }

            if (string.IsNullOrWhiteSpace(scenarioName))
            {
                throw new System.ArgumentNullException(nameof(scenarioName));
            }

            var featureClass = FeatureClass.FromFeatureInstance(featureInstance);
            var featureFile  = _featureFileRepository.GetByFilePath(featureClass.FeatureFilePath);

            var scenario = featureClass.ExtractScenario(scenarioName, featureFile);
            await scenario.ExecuteAsync(new ScenarioOutput(featureInstance.Output));
        }
        public global::Gherkin.Ast.Feature Discover(Type featureClassType)
        {
            if (featureClassType == null)
            {
                throw new ArgumentNullException(nameof(featureClassType));
            }

            var fileName    = FeatureClassInfo.FromFeatureClassType(featureClassType).FeatureFilePath;
            var featureFile = _featureFileRepository.GetByFilePath(fileName);

            if (featureFile == null)
            {
                throw new System.IO.FileNotFoundException("Feature file not found.", fileName);
            }

            var feature = featureFile.GherkinDocument.Feature;

            return(feature);
        }
Esempio n. 5
0
        public async Task ExecuteScenarioOutlineAsync(
            Feature featureInstance,
            string scenarioOutlineName,
            string exampleName,
            int exampleRowIndex)
        {
            if (featureInstance == null)
            {
                throw new ArgumentNullException(nameof(featureInstance));
            }

            if (string.IsNullOrWhiteSpace(scenarioOutlineName))
            {
                throw new ArgumentNullException(nameof(scenarioOutlineName));
            }

            if (exampleRowIndex < 0)
            {
                throw new ArgumentException($"`{nameof(exampleRowIndex)}` must be positive", nameof(exampleRowIndex));
            }

            var featureClass = FeatureClass.FromFeatureInstance(featureInstance);
            var featureFile  = _featureFileRepository.GetByFilePath(featureClass.FeatureFilePath);

            var gherkinScenarioOutline = featureFile.GetScenarioOutline(scenarioOutlineName);

            if (gherkinScenarioOutline == null)
            {
                throw new InvalidOperationException($"Cannot find scenario outline `{scenarioOutlineName}`.");
            }

            var gherkinScenario   = gherkinScenarioOutline.ApplyExampleRow(exampleName, exampleRowIndex);
            var gherkinBackground = featureFile.GetBackground();

            if (gherkinBackground != null)
            {
                gherkinScenario = gherkinScenario.ApplyBackground(gherkinBackground);
            }

            var scenario = featureClass.ExtractScenario(gherkinScenario);
            await scenario.ExecuteAsync(new ScenarioOutput(featureInstance.InternalOutput));
        }