public static InvocationCommandData FromJObject(JObject source) { List <InvocationUnit> invocationList = new List <InvocationUnit>(); JToken invocationListToken = source.GetValue(nameof(Invocations)); foreach (JObject invocationUnit in (JArray)invocationListToken) { InvocationUnit unit = InvocationUnit.FromJObject(invocationUnit); invocationList.Add(unit); } return(new InvocationCommandData(invocationList)); }
public void CreateBaselineComparison(bool debugCompareOnly) { if (!debugCompareOnly) { CopyExistingBaseline(); } ReadBaselineMasterReport(); AssignRelativePathsAndReportNamesToCommandsFromMasterReport(); if (!debugCompareOnly) { if (!TryCreateTemplates()) { throw new Exception("There were problems creating the templates to compare."); } } IReadOnlyList <InvocationUnit> invocationUnits = _masterReport.Invocations.Select(x => InvocationUnit.FromInvocationBaselineUnit(x)).ToList(); BaselineReportCreator reportCreator = new BaselineReportCreator(_masterDataBasePath, _comparisonDataDir, invocationUnits, _unitNameAndCommandToDataPathMap, _unitNameAndCommandToReportFileMap); reportCreator.WriteAllBaselineComparisons(_comparisonReportDir, _masterReport.NewCommand); }
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); }