/// <summary> /// Converts a ConclusioEnum to a human friendly string. /// The verb "Humanize" is taken from this great project: [Humanizer](https://github.com/MehdiK/Humanizer) /// </summary> /// <param name="conclusion">Conclusion to retrieve a humanized string for</param> /// <returns>The humanized string</returns> public static string ConclusionHumanized(ConclusionEnum conclusion) { switch (conclusion) { case ConclusionEnum.Success: return("OK (Success)"); case ConclusionEnum.DoesNotApply: return("N/A (Does not apply)"); case ConclusionEnum.Fatal: return("Crashed (Fatal)"); case ConclusionEnum.Inconclusive: return("Inconclusive"); case ConclusionEnum.Major: return("Major"); case ConclusionEnum.Minor: return("Minor"); default: throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", conclusion.ToString())); } }
/// <summary> /// Returns a recommended action for the user, based on the conclusion. /// This exists only for tests, because for assets there is never a recommended action. /// </summary> /// <param name="conclusion">Conclusion to get a recommended action for</param> /// <returns>An empty string if no recommended action exist, or the recommended action</returns> public static string TestRecordConclusionRecommendedAction(ConclusionEnum conclusion) { switch (conclusion) { case ConclusionEnum.Success: case ConclusionEnum.DoesNotApply: case ConclusionEnum.Inconclusive: case ConclusionEnum.Fatal: //The user can't do anything about a fatal test return(""); case ConclusionEnum.Major: return("Investigate and fix the issue immediately"); case ConclusionEnum.Minor: return("Investigate and fix the issue when time permits"); default: throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", conclusion.ToString())); } }
/// <summary> /// Returns a sentence that describes the conclusion for an AssetRecord. /// </summary> /// <param name="conclusion">Conclusion to return a sentence for</param> /// <returns>A sentence describing the conclusion</returns> public static string AssetRecordConclusionDescription(ConclusionEnum conclusion) { switch (conclusion) { case ConclusionEnum.Success: return("The asset successfully retrieved information"); //Different from TestRecord case ConclusionEnum.DoesNotApply: return("The asset does not apply to this computer and can safely be ignored"); case ConclusionEnum.Fatal: return("The asset did not execute correctly and was shut down"); //These cases are invalid for assets and will therefore result in an exception case ConclusionEnum.Inconclusive: case ConclusionEnum.Major: case ConclusionEnum.Minor: throw new ArgumentException(string.Format("ConclusionEnum {0} is not valid for an AssetRecord", conclusion.ToString())); default: throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", conclusion.ToString())); } }
/// <summary> /// Returns a sentence that describes the conclusion for a TestRecord. /// </summary> /// <param name="conclusion">Conclusion to return text for</param> /// <returns>A sentence describing the conclusiong</returns> public static string TestRecordConclusionDescription(ConclusionEnum conclusion) { switch (conclusion) { case ConclusionEnum.Success: //Alternative: The test found no issues, your system is operating within established parameters return("The test found no issues"); case ConclusionEnum.DoesNotApply: return("The test does not apply to this computer and can safely be ignored"); case ConclusionEnum.Fatal: return("The test script failed to execute correctly and was shut down"); case ConclusionEnum.Inconclusive: //Alternative: Not enough data to concluse a result return("The test did not find enough data to conclude a result"); case ConclusionEnum.Major: //Alternative: An major issue was found return("The test found a major issue"); case ConclusionEnum.Minor: //Alternative: A little irregularity was found return("The test found a little irregularity"); default: throw new ArgumentOutOfRangeException(string.Format("Found unknown ConclusionEnum: {0}", conclusion.ToString())); } }