void ProcessHashtableOutputInternal(BaseRecord record, Hashtable table) { //We need a a key "Data" or this is considered to be fatal. The value of this key can still be NULL. if (table.ContainsKey(Xteq5EngineConstant.ReturnedHashtableKeyData) == false) { record.Conclusion = ConclusionEnum.Fatal; record.AddLineToProcessMessages("Data key missing from returned hashtable"); ProcessFailure(record); } else { string name = GetStringFromHashtable(table, Xteq5EngineConstant.ReturnedHashtableKeyName); if (string.IsNullOrEmpty(name) == false) { record.Name = name; } string text = GetStringFromHashtable(table, Xteq5EngineConstant.ReturnedHashtableKeyText); if (string.IsNullOrEmpty(text) == false) { record.Description = text; } string data = GetStringFromHashtable(table, Xteq5EngineConstant.ReturnedHashtableKeyData); if (string.IsNullOrEmpty(data)) { //Empty data means DoesNotApply record.Conclusion = ConclusionEnum.DoesNotApply; ProcessEmptyData(record, table); } else { //The data key contains something. First try if the result is maybe the string "n/a" ConclusionEnum conclusion = ConclusionEnumConverter.ParseConclusion(data); if (conclusion == ConclusionEnum.DoesNotApply) { //The script returned n/a (DoesNotApply), so it can be processed as an empty record record.Conclusion = ConclusionEnum.DoesNotApply; ProcessEmptyData(record, table); } else { //The result was something else. Let the implementation decide. ProcessNonEmptyData(record, table, data); } } } }
protected override void ProcessNonEmptyData(BaseRecord record, Hashtable table, string dataKeyValue) { //The basic values are all set by :base() and it was also validated that the hashtable contains a key ".Data". TestRecord testRecord = new TestRecord(record); //Data is not NULL and not "", hence we need to check which conclusion the author wanted to report ConclusionEnum conclusion = ConclusionEnumConverter.ParseConclusion(dataKeyValue); if (conclusion == ConclusionEnum.Fatal) { //We were not able to parse the value inside .Data testRecord.AddLineToProcessMessages(string.Format("Unable to parse result {0}", dataKeyValue)); } testRecord.Conclusion = conclusion; _results.Add(testRecord); }