Esempio n. 1
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()));
            }
        }
Esempio n. 2
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));
 }