예제 #1
0
 private void ReplaceResultTextInternal()
 {
     ReplaceResultTextInternal("ResultText.DoesNotApply", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.DoesNotApply));
     ReplaceResultTextInternal("ResultText.Success", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.Success));
     ReplaceResultTextInternal("ResultText.Fatal", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.Fatal));
     ReplaceResultTextInternal("ResultText.Inconclusive", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.Inconclusive));
     ReplaceResultTextInternal("ResultText.Major", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.Major));
     ReplaceResultTextInternal("ResultText.Minor", ConclusionEnumConverter.ConclusionHumanized(ConclusionEnum.Minor));
 }
예제 #2
0
        /// <summary>
        /// Initalize this class with a record with recommended values for a BaseRecord
        /// </summary>
        /// <param name="record"></param>
        internal ResultPrimarySecondary(BaseRecord record)
        {
            //Short-circut some values
            Conclusion = record.Conclusion;
            string description = string.IsNullOrWhiteSpace(record.Description) ? string.Empty : record.Description;

            switch (Conclusion)
            {
            //The primary result for these conclusion is always our pre-set value and (if available) the description from the script as secondary
            case ConclusionEnum.Success:
            case ConclusionEnum.DoesNotApply:
            case ConclusionEnum.Fatal:

                //Set Primary to a descriptive text, e.g. Conclusiong==Success -> "OK (Success)"
                Primary = ConclusionEnumConverter.ConclusionHumanized(Conclusion);

                if (record is AssetRecord)
                {
                    //For an asset that returned SUCCESS, the VALUE the asset has retrieved is the interessting part, hence change primary to the value
                    if (Conclusion == ConclusionEnum.Success)
                    {
                        Primary = (record as AssetRecord).Data;
                    }

                    //Assign to secondary either the default conclusion description or the one from the script
                    Secondary = string.IsNullOrWhiteSpace(description) ? ConclusionEnumConverter.AssetRecordConclusionDescription(Conclusion) : description;
                }
                else
                {
                    Secondary = string.IsNullOrWhiteSpace(description) ? ConclusionEnumConverter.TestRecordConclusionDescription(Conclusion) : description;
                }

                break;


            //For these conclusions, the text will be promoted to be Primary, and our internal description for the conclusion is secondary.
            //The exception for this rule is if we have text, then the value from the script will be used
            case ConclusionEnum.Inconclusive:
            case ConclusionEnum.Major:
            case ConclusionEnum.Minor:
                if (record is AssetRecord)
                {
                    Primary   = string.IsNullOrEmpty(description) ? ConclusionEnumConverter.ConclusionHumanized(Conclusion) : description;
                    Secondary = ConclusionEnumConverter.AssetRecordConclusionDescription(Conclusion);
                }
                else
                {
                    Primary   = string.IsNullOrEmpty(description) ? ConclusionEnumConverter.ConclusionHumanized(Conclusion) : description;
                    Secondary = ConclusionEnumConverter.TestRecordConclusionDescription(Conclusion);
                }
                break;


            default:
                throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", Conclusion.ToString()));
            }
        }
예제 #3
0
 private void ReplaceTestRecommendedActionTextInternal()
 {
     //Recplace recommended action for tests
     ReplaceTestRecommendedActionTextInternal("TestActionText.DoesNotApply", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.DoesNotApply));
     ReplaceTestRecommendedActionTextInternal("TestActionText.Success", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.Success));
     ReplaceTestRecommendedActionTextInternal("TestActionText.Fatal", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.Fatal));
     ReplaceTestRecommendedActionTextInternal("TestActionText.Inconclusive", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.Inconclusive));
     ReplaceTestRecommendedActionTextInternal("TestActionText.Major", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.Major));
     ReplaceTestRecommendedActionTextInternal("TestActionText.Minor", ConclusionEnumConverter.TestRecordConclusionRecommendedAction(ConclusionEnum.Minor));
 }
예제 #4
0
 private void ReplaceTestConclusionTextInternal()
 {
     //Replace text values for tests
     ReplaceTestConclusionTextInternal("TestText.DoesNotApply", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.DoesNotApply));
     ReplaceTestConclusionTextInternal("TestText.Success", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.Success));
     ReplaceTestConclusionTextInternal("TestText.Fatal", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.Fatal));
     ReplaceTestConclusionTextInternal("TestText.Inconclusive", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.Inconclusive));
     ReplaceTestConclusionTextInternal("TestText.Major", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.Major));
     ReplaceTestConclusionTextInternal("TestText.Minor", ConclusionEnumConverter.TestRecordConclusionDescription(ConclusionEnum.Minor));
 }
예제 #5
0
        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);
                    }
                }
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
 private void ReplaceAssetConclusionTextInternal()
 {
     ReplaceAssetConclusionTextInternal("AssetText.DoesNotApply", ConclusionEnumConverter.AssetRecordConclusionDescription(ConclusionEnum.DoesNotApply));
     ReplaceAssetConclusionTextInternal("AssetText.Success", ConclusionEnumConverter.AssetRecordConclusionDescription(ConclusionEnum.Success));
     ReplaceAssetConclusionTextInternal("AssetText.Fatal", ConclusionEnumConverter.AssetRecordConclusionDescription(ConclusionEnum.Fatal));
 }