Hello
In GhostDoc pro I'm editing the rule for comments.of unit test methods.
My unit test names have the following naming format:
MethodToBeTested_Condition_ExpectedResult
I'd like to generate a summary of the following format:
"Checks that if MethodToBeTested is called with Condition, then ExpectedResult is returned."
I've already adapted the corresponding part in the rule according to the following:
// Check the setting for the test methods documentation option. Default value is "true".
else if((bool)Context.GetSettingValue("UseTestMethodTemplate", true) && IsTestMethod())
{
string[] parts = Context.CurrentCodeElement.Name.Split('_');
System.Text.StringBuilder summary = new System.Text.StringBuilder("Checks that if ");
if (parts.Length >= 1)
{
summary.AppendFormat("{0} is called", parts[0]);
}
if (parts.Length >= 2)
{
summary.AppendFormat(" with {0}", parts[1]);
}
if (parts.Length >= 3)
{
summary.AppendFormat(", then {0} is returned.", parts[2]);
}
this.WriteLine(summary.ToString());
}
This works.
However, the condition consists quite often of multiple words (e.g., "XLarger2AndYNegative").
Therefore, I'd like to split the condition part into words (e.g., x larger 2 and y negative").
I've tried to use the Words macro and the Context.GetWords method. But I was not able to figure out a way to use them on a string. How could I do that?
Any help appreciated
-- rotello