private static TestCase? GetTestFromNode()

in src/extensions/testframework/YamlTestCaseParser.cs [282:347]


        private static TestCase? GetTestFromNode(YamlTestCaseParseContext context, YamlMappingNode? mapping, int stepNumber = 0)
        {
            if (mapping == null) return null;

            var cli = GetScalarString(mapping, context.Tags, "cli");
            var parallelize = GetScalarString(mapping, context.Tags, "parallelize");
            var skipOnFailure = GetScalarString(mapping, context.Tags, "skipOnFailure");
            string workingDirectory = UpdateWorkingDirectory(mapping!, context.WorkingDirectory);

            var command = GetScalarString(mapping, "command");
            var script = GetScalarString(mapping, "script");
            var bash = GetScalarString(mapping, "bash");

            var fullyQualifiedName = command == null && script == null && bash == null
                ? GetFullyQualifiedNameAndCommandFromShortForm(mapping, context.Area, context.Class, ref command, stepNumber)
                : GetFullyQualifiedName(mapping, context.Area, context.Class, stepNumber);
            fullyQualifiedName ??= GetFullyQualifiedName(context.Area, context.Class, $"Expected YAML node ('name') at {context.File.FullName}({mapping.Start.Line})", 0);

            var neitherOrBoth = (command == null) == (script == null && bash == null);
            if (neitherOrBoth)
            {
                var message = $"Error parsing YAML: expected/unexpected key ('name', 'command', 'script', 'bash', 'arguments') at {context.File.FullName}({mapping.Start.Line})";
                Logger.LogError(message);
                return null;
            }

            Logger.Log($"YamlTestCaseParser.GetTests(): new TestCase('{fullyQualifiedName}')");
            var test = new TestCase(fullyQualifiedName, new Uri(YamlTestFramework.FakeExecutor), context.Source)
            {
                CodeFilePath = context.File.FullName,
                LineNumber = mapping.Start.Line
            };

            SetTestCaseProperty(test, "cli", cli);
            SetTestCaseProperty(test, "command", command);
            SetTestCaseProperty(test, "script", script);
            SetTestCaseProperty(test, "bash", bash);
            SetTestCaseProperty(test, "parallelize", parallelize);
            SetTestCaseProperty(test, "skipOnFailure", skipOnFailure);

            var timeout = GetScalarString(mapping, context.Tags, "timeout", YamlTestFramework.DefaultTimeout);
            SetTestCaseProperty(test, "timeout", timeout);

            SetTestCaseProperty(test, "working-directory", workingDirectory);

            var processEnv = YamlEnvHelpers.GetCurrentProcessEnvironment();
            var testEnv = YamlEnvHelpers.UpdateCopyEnvironment(context.Environment, mapping);
            testEnv = YamlEnvHelpers.GetNewAndUpdatedEnvironmentVariables(processEnv, testEnv);
            SetTestCasePropertyMap(test, "env", testEnv);

            var matrix = JsonHelpers.GetJsonArrayText(context.Matrix);
            SetTestCaseProperty(test, "matrix", matrix);

            SetTestCasePropertyMap(test, "foreach", mapping, "foreach", workingDirectory);
            SetTestCasePropertyMap(test, "arguments", mapping, "arguments", workingDirectory);
            SetTestCasePropertyMap(test, "input", mapping, "input", workingDirectory);

            SetTestCaseProperty(test, "expect", mapping, "expect");
            SetTestCaseProperty(test, "expect-regex", mapping, "expect-regex");
            SetTestCaseProperty(test, "not-expect-regex", mapping, "not-expect-regex");

            SetTestCaseTagsAsTraits(test, YamlTagHelpers.UpdateCopyTags(context.Tags, mapping));

            CheckInvalidTestCaseNodes(context, mapping, test);
            return test;
        }