private IReadOnlyList <BaselineCommandData> WriteBaselineComparisonsForInvocationUnit(InvocationUnit unit, string reportDir, string newCommand)
        {
            if (!_unitNameAndCommandToDataPathMap.TryGetValue(unit.Name, out IReadOnlyDictionary <string, string> commandToDataRelativePathMap))
            {
                throw new Exception($"Invocation unit {unit.Name} didn't have a command-path map");
            }

            if (!_unitNameAndCommandToReportFileMap.TryGetValue(unit.Name, out IReadOnlyDictionary <string, string> commandToReportFileMap))
            {
                throw new Exception($"Invocation unit {unit.Name} didn't have a report file map");
            }

            IReadOnlyDictionary <string, DirectoryDifference> comparisonsForUnit = CreateComparisonsForInvocationUnit(commandToDataRelativePathMap);
            List <BaselineCommandData> commandInfoList = new List <BaselineCommandData>();

            foreach (KeyValuePair <string, DirectoryDifference> commandComparison in comparisonsForUnit)
            {
                string command = commandComparison.Key;
                if (!commandToDataRelativePathMap.TryGetValue(command, out string relativePath))
                {
                    throw new Exception($"Unit '{unit.Name}' data map didnt have a data path for command: '{command}'");
                }

                CommandBaseline baselineForCommand = new CommandBaseline()
                {
                    InvocationName = unit.Name,
                    Command        = command,
                    NewCommand     = newCommand,
                    FileResults    = commandComparison.Value
                };

                if (!commandToReportFileMap.TryGetValue(command, out string reportFilename))
                {
                    throw new Exception($"Unit '{unit.Name}' report map didnt have a report file for command: '{command}'");
                }

                string  reportFileFullPath = Path.Combine(reportDir, reportFilename);
                JObject serialized         = JObject.FromObject(baselineForCommand);

                File.WriteAllText(reportFileFullPath, serialized.ToString());

                BaselineCommandData dataForCommand = new BaselineCommandData()
                {
                    Command        = command,
                    RelativePath   = relativePath,
                    ReportFileName = reportFilename
                };
                commandInfoList.Add(dataForCommand);
            }

            return(commandInfoList);
        }
        private void CreateCommonFileComparisonReports(string comparisonComparisonReportDir)
        {
            foreach (string differenceReportFilename in _commonReportFiles)
            {
                string              baselineReportPath = Path.Combine(_baselineReportDir, differenceReportFilename);
                CommandBaseline     baselineBaseline   = CommandBaseline.FromFile(baselineReportPath);
                DirectoryDifference baselineDifference = baselineBaseline.FileResults;

                string              comparisonReportPath = Path.Combine(_comparisonReportDir, differenceReportFilename);
                CommandBaseline     comparisonBaseline   = CommandBaseline.FromFile(comparisonReportPath);
                DirectoryDifference comparisonDifference = comparisonBaseline.FileResults;


                DirectoryDifferenceComparer             comparer             = new DirectoryDifferenceComparer(baselineDifference, comparisonDifference);
                DirectoryComparisonDifference           comparisonComparison = comparer.Compare();
                StructuredDirectoryComparisonDifference structuredDifference = StructuredDirectoryComparisonDifference.FromDirectoryComparisonDifference(comparisonComparison);

                JObject serialized = JObject.FromObject(structuredDifference);
                string  comparisonComparisonReportFile = Path.Combine(comparisonComparisonReportDir, differenceReportFilename);
                File.WriteAllText(comparisonComparisonReportFile, serialized.ToString());
            }
        }