-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnumTest.cs
80 lines (67 loc) · 2.21 KB
/
EnumTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections.Generic;
using System.Runtime.Serialization;
using BabouExtensions.Helpers;
using BabouExtensions.Test.Helpers;
using Xunit;
namespace BabouExtensions.Test
{
public class EnumTest
{
[Fact]
public void GetEnumFromDescription_From_String()
{
var here = "HereDescription".GetEnumValueFromDescription<FunEnums>();
Assert.Equal(FunEnums.Here, here);
}
[Fact]
public void GetEnumFromDisplayName_From_String()
{
var here = "HereDisplay".GetEnumFromDisplayName<FunEnums>();
Assert.Equal(FunEnums.Here, here);
}
[Fact]
public void ParseEnum_From_String()
{
var here = "Here".ParseEnum(FunEnums.Here);
Assert.Equal(FunEnums.Here, here);
}
[Fact]
public void GetAttrEnumMemberAttribute()
{
var here = FunEnums.Here.GetAttributeOfType<EnumMemberAttribute>().Value;
Assert.Equal("HereEnumMember", here);
}
[Fact]
public void GetDisplayName_With_Specified()
{
var here = FunEnums.Here.GetDisplayName();
Assert.Equal("HereDisplay", here);
}
[Fact]
public void GetDisplayName_Without_Specified()
{
var everywhere = FunEnums.Everywhere.GetDisplayName();
Assert.Equal("Everywhere", everywhere);
}
[Fact]
public void GetDescriptionAttr()
{
var everywhere = FunEnums.Everywhere.GetDescriptionAttr();
Assert.Equal("Everywhere", everywhere);
}
[Fact]
public void GetListByDescriptionAttr()
{
var funEnumList = BabouEnum<FunEnums>.GetListByDescriptionAttr();
var funStringList = new List<string>() {"HereDescription", "Everywhere"};
Assert.Equal(funStringList, funEnumList);
}
[Fact]
public void GetListByDisplayAttr()
{
var funEnumList = BabouEnum<FunEnums>.GetListByDisplayAttr();
var funStringList = new List<string>() { "HereDisplay", "Everywhere" };
Assert.Equal(funStringList, funEnumList);
}
}
}