Example #1
0
        public async Task RunTests_GivenTestResultsReturnedFromExecutorWhereNoStepsExecuted_ReturnsOneIgnoreTestResult()
        {
            //Arrange
            ProviderResult providerResult = new ProviderResult {
                Provider = new ProviderSummary {
                    Id = ProviderId, Name = "any provider"
                }, SpecificationId = SpecificationId
            };

            IEnumerable <ProviderResult>        providerResults        = new[] { providerResult };
            IEnumerable <TestScenario>          scenarios              = new[] { new TestScenario() };
            IEnumerable <ProviderSourceDataset> providerSourceDatasets = new ProviderSourceDataset[0];
            IEnumerable <TestScenarioResult>    testScenarioResults    = new TestScenarioResult[0];

            SpecModel.SpecificationSummary specificationSummary = new SpecModel.SpecificationSummary {
                Id = SpecificationId, Name = "spec-name"
            };

            BuildProject buildProject = new BuildProject();

            IEnumerable <ScenarioResult> scenarioResults = new[]
            {
                new ScenarioResult  {
                    Scenario = new Reference("sceanrio=id", "scenario name")
                }
            };

            ILogger logger = CreateLogger();

            IGherkinExecutor gherkinExecutor = CreateGherkinExecutor();

            gherkinExecutor
            .Execute(Arg.Any <ProviderResult>(), Arg.Any <IEnumerable <ProviderSourceDataset> >(), Arg.Any <IEnumerable <TestScenario> >(), Arg.Any <BuildProject>())
            .Returns(scenarioResults);

            TestEngine testEngine = CreateTestEngine(gherkinExecutor, logger);

            //Act
            IEnumerable <TestScenarioResult> results = await testEngine.RunTests(scenarios, providerResults, providerSourceDatasets,
                                                                                 testScenarioResults, specificationSummary, buildProject);

            results
            .Count()
            .Should()
            .Be(1);

            results
            .First()
            .TestResult
            .Should()
            .Be(TestResult.Ignored);
        }
        private async Task <IEnumerable <ScenarioResult> > RunTests(IEnumerable <TestScenario> testScenarios, ProviderResult providerResult,
                                                                    IEnumerable <ProviderSourceDataset> providerSourceDatasets, BuildProject buildProject)
        {
            List <ScenarioResult> scenarioResults = new List <ScenarioResult>();

            if (testScenarios != null)
            {
                IEnumerable <ScenarioResult> gherkinScenarioResults =
                    await _gherkinExecutor.Execute(providerResult, providerSourceDatasets, testScenarios, buildProject);

                if (!gherkinScenarioResults.IsNullOrEmpty())
                {
                    scenarioResults.AddRange(gherkinScenarioResults);
                }
            }

            return(scenarioResults);
        }