Skip to content

Commit 24fc5ec

Browse files
committed
Added tests and updated Flag
1 parent a4555d5 commit 24fc5ec

File tree

4 files changed

+80
-5
lines changed

4 files changed

+80
-5
lines changed

spkl/SparkleXrm.Tasks.Tests/EarlyBoundTypes.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,82 @@ namespace SparkleXrm.Tasks.Tests
1313
[TestClass]
1414
public class EarlyBoundTypes
1515
{
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+
1692
[TestMethod]
1793
[TestCategory("Integration Tests")]
1894
public void TestGenerateGlobalOptionsets()

spkl/SparkleXrm.Tasks.Tests/app.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<connectionStrings>
44
<add name="integration_testing" connectionString="Url=http://dev04/Contoso" />
55
</connectionStrings>
6-
6+
77
<runtime>
88
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
99

@@ -73,7 +73,7 @@
7373
</dependentAssembly>
7474
<dependentAssembly>
7575
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
76-
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
76+
<bindingRedirect oldVersion="0.0.0.0-3.19.8.0" newVersion="3.19.8.0" />
7777
</dependentAssembly>
7878
<dependentAssembly>
7979
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

spkl/SparkleXrm.Tasks/Config/EarlyBoundTypeConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class EarlyBoundTypeConfig : DLaB.EarlyBoundGenerator.Settings.POCO.ExtensionConfig
44
{
5-
public bool useEarlyBoundGenerator;
5+
public bool useEarlyBoundGeneratorApi;
66

77
public string profile;
88
public string entities;
@@ -24,7 +24,6 @@ public class EarlyBoundTypeConfig : DLaB.EarlyBoundGenerator.Settings.POCO.Exten
2424

2525
#region Early Bound Generator Specific
2626

27-
2827
public bool? generateActions;
2928
public string actionFilename;
3029
public string optionSetFilename;

spkl/SparkleXrm.Tasks/Tasks/EarlyBoundClassGeneratorTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void CreateEarlyBoundTypes(OrganizationServiceContext ctx, ConfigFile con
4747
var earlyBoundTypeConfigs = config.GetEarlyBoundConfig(Profile);
4848
foreach (var earlyboundConfig in earlyBoundTypeConfigs)
4949
{
50-
if (earlyboundConfig.useEarlyBoundGenerator)
50+
if (earlyboundConfig.useEarlyBoundGeneratorApi)
5151
{
5252
ProcessEbgGeneration(config, earlyboundConfig, crmSvcUtilPath);
5353
}

0 commit comments

Comments
 (0)