Skip to content

Commit b4f62e5

Browse files
committed
added support for DescriptionAttribute
1 parent a9f1d0e commit b4f62e5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

ConventionTests/Conventions/Internal/ConventionTestBase.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
namespace ConventionTests
22
{
3+
using System.ComponentModel;
34
using ApprovalTests;
45

56
public abstract class ConventionTestBase : IConventionTest
67
{
78
public virtual string Name
89
{
9-
get { return GetType().Name.Replace('_', ' '); }
10+
get
11+
{
12+
var descriptions = GetType().GetCustomAttributes(typeof (DescriptionAttribute), false);
13+
if (descriptions.Length == 1)
14+
{
15+
return ((DescriptionAttribute) descriptions[0]).Description;
16+
}
17+
return GetType().Name.Replace('_', ' ');
18+
}
1019
}
1120

1221
public abstract void Execute(IAssert assert);
1322

1423
protected void Approve(string message)
1524
{
16-
Approvals.Verify(new ApprovalTextWriter(message), new ConventionTestNamer(GetType().Name),
25+
Approvals.Verify(new ApprovalTextWriter(message),
26+
new ConventionTestNamer(GetType().Name),
1727
Approvals.GetReporter());
1828
}
1929
}

0 commit comments

Comments
 (0)