private ICollection <IXunitTestCase> CreatePreEnumeratedTestCases(
            ITestFrameworkDiscoveryOptions discoveryOptions,
            ITestMethod testMethod, IEnumerable <IAttributeInfo> scenarioAttributes)
        {
            var testCases = new List <IXunitTestCase>();

            foreach (var scenarioAttribute in scenarioAttributes)
            {
                IScenarioIdentifier scenarioIdentifier;
                var skipReason = scenarioAttribute.GetNamedArgument <string>(nameof(ScenarioAttribute.Skip));

                try
                {
                    var scenarioDiscoverer =
                        ScenarioDiscovererFactory.GetDiscoverer(DiagnosticMessageSink, scenarioAttribute);
                    scenarioIdentifier = scenarioDiscoverer.GetScenarioIdentifier(scenarioAttribute);
                }
                catch (Exception e)
                {
                    scenarioIdentifier = new DummyScenarioDiscoverer().GetScenarioIdentifier(scenarioAttribute);

                    if (skipReason == null)
                    {
                        testCases.Add(
                            new ExecutionErrorScenarioTestCase(
                                DiagnosticMessageSink,
                                discoveryOptions.MethodDisplayOrDefault(),
                                discoveryOptions.MethodDisplayOptionsOrDefault(),
                                testMethod,
                                scenarioIdentifier,
                                $"{e.Message} for {testMethod.TestClass.Class.Name}.{testMethod.Method.Name}, Scenario {scenarioIdentifier}."
                                )
                            );

                        continue;
                    }
                }

                var testCase = new ScenarioTestCase(DiagnosticMessageSink,
                                                    discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(),
                                                    testMethod, scenarioIdentifier, skipReason);

                testCases.Add(testCase);
            }

            return(testCases);
        }
        protected override async Task AfterTestCaseStartingAsync()
        {
            await base.AfterTestCaseStartingAsync();

            try
            {
                var scenarioAttributes = TestCase.TestMethod.GetScenarioAttributes(DiagnosticMessageSink);

                if (!scenarioAttributes.Any())
                {
                    throw new InvalidOperationException(
                              $"No scenario specified for {TestCase.TestMethod.TestClass.Class.Name}.{TestCase.TestMethod.Method.Name}. Make sure to add at least one ScenarioAttribute to the test method or class.");
                }

                foreach (var scenarioAttribute in scenarioAttributes)
                {
                    IScenarioIdentifier scenarioIdentifier = null;
                    var testRunnerAggregator = new ExceptionAggregator(Aggregator);
                    var skipReason           = scenarioAttribute.GetNamedArgument <string>("Skip");

                    try
                    {
                        var scenarioDiscoverer = ScenarioDiscovererFactory.GetDiscoverer(DiagnosticMessageSink, scenarioAttribute);
                        scenarioIdentifier = scenarioDiscoverer.GetScenarioIdentifier(scenarioAttribute);
                    }
                    catch (Exception exception)
                    {
                        scenarioIdentifier = new DummyScenarioDiscoverer().GetScenarioIdentifier(scenarioAttribute);
                        testRunnerAggregator.Add(exception);
                    }

                    var test       = CreateTest(TestCase, scenarioIdentifier);
                    var testRunner = new ScenarioTestRunner(test, DiagnosticMessageSink, MessageBus, TestClass, ConstructorArguments, TestMethod,
                                                            TestMethodArguments, skipReason, BeforeAfterAttributes, testRunnerAggregator,
                                                            CancellationTokenSource);

                    _testRunners.Add(testRunner);
                }
            }
            catch (Exception ex)
            {
                ScenarioDiscoveryException = ex;
            }
        }