@@ -13,6 +13,82 @@ namespace SparkleXrm.Tasks.Tests
13
13
[ TestClass ]
14
14
public class EarlyBoundTypes
15
15
{
16
+ [ TestMethod ]
17
+ [ TestCategory ( "Integration Tests" ) ]
18
+ public void TestEbgGenerateGlobalOptionsets ( )
19
+ {
20
+ // Arrange
21
+ Guid id = Guid . NewGuid ( ) ;
22
+ var tempFolder = Path . Combine ( Path . GetTempPath ( ) , id . ToString ( ) ) ;
23
+ Directory . CreateDirectory ( tempFolder ) ;
24
+ try
25
+ {
26
+ var config = new ConfigFile
27
+ {
28
+ earlyboundtypes = new List < EarlyBoundTypeConfig > {
29
+ new EarlyBoundTypeConfig {
30
+ useEarlyBoundGeneratorApi = true ,
31
+ generateOptionsetEnums = true ,
32
+ entities = "socialprofile,socialactivity"
33
+ }
34
+ } ,
35
+ filePath = tempFolder
36
+
37
+ } ;
38
+ Generate ( tempFolder , config ) ;
39
+
40
+ // Check that there was only a single instance of the global optionsset 'socialprofile_community'
41
+ // public enum socialprofile_community
42
+
43
+ var matches = CountMatches ( "public enum SocialProfile_Community" , tempFolder ) ;
44
+ Assert . AreEqual ( 1 , matches , "Global optionset created once only" ) ;
45
+ }
46
+ finally
47
+ {
48
+ Directory . Delete ( tempFolder , true ) ;
49
+ }
50
+ }
51
+
52
+ [ TestMethod ]
53
+ [ TestCategory ( "Integration Tests" ) ]
54
+ public void TestEbgGenerateGlobalOptionsets_OneTypePerFile ( )
55
+ {
56
+ // Arrange
57
+ Guid id = Guid . NewGuid ( ) ;
58
+ var tempFolder = Path . Combine ( Path . GetTempPath ( ) , id . ToString ( ) ) ;
59
+ Directory . CreateDirectory ( tempFolder ) ;
60
+ try
61
+ {
62
+ var config = new ConfigFile
63
+ {
64
+ earlyboundtypes = new List < EarlyBoundTypeConfig > {
65
+ new EarlyBoundTypeConfig {
66
+ generateOptionsetEnums = true ,
67
+ useEarlyBoundGeneratorApi = true ,
68
+ entities = "socialprofile,socialactivity" ,
69
+ oneTypePerFile = true
70
+ }
71
+ } ,
72
+ filePath = tempFolder
73
+
74
+ } ;
75
+ Generate ( tempFolder , config ) ;
76
+
77
+
78
+ Assert . IsFalse ( File . Exists ( Path . Combine ( tempFolder , "entities.cs" ) ) ) ;
79
+
80
+ EnsureClassIsCreatedCorrectly ( Path . Combine ( $ "{ tempFolder } \\ Entities", "SocialProfile.cs" ) , "SocialProfile" ) ;
81
+ EnsureClassIsCreatedCorrectly ( Path . Combine ( $ "{ tempFolder } \\ Entities", "SocialActivity.cs" ) , "SocialActivity" ) ;
82
+
83
+ EnsureOptionSetsIsCreatedCorrectly ( Path . Combine ( $ "{ tempFolder } \\ OptionSets", "socialprofile_community.cs" ) , "SocialProfile_Community" ) ;
84
+ EnsureOptionSetsIsCreatedCorrectly ( Path . Combine ( $ "{ tempFolder } \\ OptionSets", "socialactivity_prioritycode.cs" ) , "SocialActivity_PriorityCode" ) ;
85
+ }
86
+ finally
87
+ {
88
+ Directory . Delete ( tempFolder , true ) ;
89
+ }
90
+ }
91
+
16
92
[ TestMethod ]
17
93
[ TestCategory ( "Integration Tests" ) ]
18
94
public void TestGenerateGlobalOptionsets ( )
0 commit comments