-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honors any attribute with a string Description property - fixes #97
- Loading branch information
Showing
7 changed files
with
99 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,62 @@ | ||
using System.ComponentModel; | ||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace Humanizer.Tests | ||
{ | ||
public enum EnumUnderTest | ||
{ | ||
[Description(EnumTestsResources.CustomDescription)] | ||
[Description(EnumTestsResources.MemberWithDescriptionAttribute)] | ||
MemberWithDescriptionAttribute, | ||
[DescriptionSubclass(EnumTestsResources.MemberWithDescriptionAttributeSubclass)] | ||
MemberWithDescriptionAttributeSubclass, | ||
[CustomDescription(EnumTestsResources.MemberWithCustomDescriptionAttribute)] | ||
MemberWithCustomDescriptionAttribute, | ||
[ImposterDescription(42)] | ||
MemberWithImposterDescriptionAttribute, | ||
MemberWithoutDescriptionAttribute, | ||
ALLCAPITALS | ||
} | ||
|
||
public class EnumTestsResources | ||
{ | ||
public const string MemberWithDescriptionAttribute = "Some Description"; | ||
public const string MemberWithDescriptionAttributeSubclass = "Description in Description subclass"; | ||
public const string MemberWithCustomDescriptionAttribute = "Description in custom Description attribute"; | ||
public const string MemberWithImposterDescriptionAttribute = "Member with imposter description attribute"; | ||
public const string MemberWithoutDescriptionAttributeSentence = "Member without description attribute"; | ||
public const string MemberWithoutDescriptionAttributeTitle = "Member Without Description Attribute"; | ||
public const string MemberWithoutDescriptionAttributeLowerCase = "member without description attribute"; | ||
} | ||
|
||
public class ImposterDescriptionAttribute : Attribute | ||
{ | ||
public int Description { get; set; } | ||
|
||
public ImposterDescriptionAttribute(int description) | ||
{ | ||
Description = description; | ||
} | ||
} | ||
|
||
public class CustomDescriptionAttribute : Attribute | ||
{ | ||
public string Description { get; set; } | ||
|
||
public CustomDescriptionAttribute(string description) | ||
{ | ||
Description = description; | ||
} | ||
} | ||
|
||
public class DescriptionSubclassAttribute : DescriptionAttribute | ||
{ | ||
public DescriptionSubclassAttribute(string description):base(description) | ||
{ | ||
} | ||
|
||
public override string Description | ||
{ | ||
get { return "Overridden " + base.Description; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters