Ejemplo 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()));
            }
        }
Ejemplo n.º 2
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));
 }