Skip to content

Commit be07c29

Browse files
author
Summer
authored
add test cases to cover fsharp (#13)
1 parent 80e168c commit be07c29

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

Test/Test.cs

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Test
99
{
1010
public class DotNetFixture : IDisposable
1111
{
12-
private static string RelativeTemplatePath = @"../../../../content/dotnet-template-azure-iot-edge-module/CSharp/";
12+
private static string RelativeTemplatePath = @"../../../../content/dotnet-template-azure-iot-edge-module/";
1313
public DotNetFixture()
1414
{
1515
Process.Start("dotnet", "new -i " + RelativeTemplatePath).WaitForExit();
@@ -30,6 +30,8 @@ public class Test : IClassFixture<DotNetFixture>
3030
private DotNetFixture fixture;
3131
private const string TargetAll = "all";
3232
private const string TargetDeploy = "deploy";
33+
private const string CSharp = "C#";
34+
private const string FSharp = "F#";
3335
private const string ArchLinux64 = "linux64";
3436
private const string ArchWindowsNano = "windowsNano";
3537

@@ -60,35 +62,58 @@ public Test(DotNetFixture fixture)
6062
}
6163
};
6264

63-
private static string BeforeEach(string target = TargetAll, bool linux64 = true, bool windowsNano = true, bool skipRestore = false)
65+
private static string BeforeEach(string lang, string target, bool linux64 = true, bool windowsNano = true, bool skipRestore = false)
6466
{
6567
var scaffoldName = Path.GetRandomFileName().Replace(".", "").ToString();
66-
FlagFilesMapping[TargetAll] = new List<string> {scaffoldName + ".csproj", "Program.cs", ".gitignore"};
67-
var command = "new aziotedgemodule -n " + scaffoldName + " -t " + target + " -lx " + linux64 + " -wn " + windowsNano + " -s " + skipRestore;
68+
if(lang == CSharp)
69+
{
70+
FlagFilesMapping[TargetAll] = new List<string> {scaffoldName + ".csproj", "Program.cs", ".gitignore"};
71+
}
72+
if(lang == FSharp)
73+
{
74+
FlagFilesMapping[TargetAll] = new List<string> {scaffoldName + ".fsproj", "Program.fs", ".gitignore"};
75+
}
76+
var command = "new aziotedgemodule -n " + scaffoldName + " -lang " + lang + " -t " + target + " -lx " + linux64 + " -wn " + windowsNano + " -s " + skipRestore;
6877
Process.Start("dotnet", command).WaitForExit();
6978
return scaffoldName;
7079
}
7180

7281
[Theory]
73-
[InlineData(TargetAll, true, true, true)]
74-
[InlineData(TargetAll, true, true, false)]
75-
[InlineData(TargetAll, true, false, true)]
76-
[InlineData(TargetAll, true, false, false)]
77-
[InlineData(TargetAll, false, true, true)]
78-
[InlineData(TargetAll, false, true, false)]
79-
[InlineData(TargetAll, false, false, true)]
80-
[InlineData(TargetAll, false, false, false)]
81-
[InlineData(TargetDeploy, true, true, true)]
82-
[InlineData(TargetDeploy, true, true, false)]
83-
[InlineData(TargetDeploy, true, false, true)]
84-
[InlineData(TargetDeploy, true, false, false)]
85-
[InlineData(TargetDeploy, false, true, true)]
86-
[InlineData(TargetDeploy, false, true, false)]
87-
[InlineData(TargetDeploy, false, false, true)]
88-
[InlineData(TargetDeploy, false, false, false)]
89-
public void TestArchitecture(string target, bool linux64, bool windowsNano, bool skipRestore)
82+
[InlineData(CSharp, TargetAll, true, true, true)]
83+
[InlineData(CSharp, TargetAll, true, true, false)]
84+
[InlineData(CSharp, TargetAll, true, false, true)]
85+
[InlineData(CSharp, TargetAll, true, false, false)]
86+
[InlineData(CSharp, TargetAll, false, true, true)]
87+
[InlineData(CSharp, TargetAll, false, true, false)]
88+
[InlineData(CSharp, TargetAll, false, false, true)]
89+
[InlineData(CSharp, TargetAll, false, false, false)]
90+
[InlineData(CSharp, TargetDeploy, true, true, true)]
91+
[InlineData(CSharp, TargetDeploy, true, true, false)]
92+
[InlineData(CSharp, TargetDeploy, true, false, true)]
93+
[InlineData(CSharp, TargetDeploy, true, false, false)]
94+
[InlineData(CSharp, TargetDeploy, false, true, true)]
95+
[InlineData(CSharp, TargetDeploy, false, true, false)]
96+
[InlineData(CSharp, TargetDeploy, false, false, true)]
97+
[InlineData(CSharp, TargetDeploy, false, false, false)]
98+
[InlineData(FSharp, TargetAll, true, true, true)]
99+
[InlineData(FSharp, TargetAll, true, true, false)]
100+
[InlineData(FSharp, TargetAll, true, false, true)]
101+
[InlineData(FSharp, TargetAll, true, false, false)]
102+
[InlineData(FSharp, TargetAll, false, true, true)]
103+
[InlineData(FSharp, TargetAll, false, true, false)]
104+
[InlineData(FSharp, TargetAll, false, false, true)]
105+
[InlineData(FSharp, TargetAll, false, false, false)]
106+
[InlineData(FSharp, TargetDeploy, true, true, true)]
107+
[InlineData(FSharp, TargetDeploy, true, true, false)]
108+
[InlineData(FSharp, TargetDeploy, true, false, true)]
109+
[InlineData(FSharp, TargetDeploy, true, false, false)]
110+
[InlineData(FSharp, TargetDeploy, false, true, true)]
111+
[InlineData(FSharp, TargetDeploy, false, true, false)]
112+
[InlineData(FSharp, TargetDeploy, false, false, true)]
113+
[InlineData(FSharp, TargetDeploy, false, false, false)]
114+
public void TestArchitecture(string lang, string target, bool linux64, bool windowsNano, bool skipRestore)
90115
{
91-
var scaffoldName = BeforeEach(target, linux64, windowsNano, skipRestore);
116+
var scaffoldName = BeforeEach(lang, target, linux64, windowsNano, skipRestore);
92117
var filesToCheck = new List<string>();
93118
if(target == TargetDeploy)
94119
{
@@ -125,10 +150,12 @@ public void TestArchitecture(string target, bool linux64, bool windowsNano, bool
125150
Directory.Delete(scaffoldName, true);
126151
}
127152

128-
[Fact]
129-
public void TestDeployUnnecessaryFiles()
153+
[Theory]
154+
[InlineData(CSharp)]
155+
[InlineData(FSharp)]
156+
public void TestDeployUnnecessaryFiles(string lang)
130157
{
131-
var scaffoldName = BeforeEach(TargetDeploy);
158+
var scaffoldName = BeforeEach(lang, TargetDeploy);
132159
var filesExistsToCheck = FlagFilesMapping[TargetDeploy];
133160
var filesNonExistsToCheck = FlagFilesMapping[ArchLinux64].Union(FlagFilesMapping[ArchWindowsNano]).Union(FlagFilesMapping[TargetAll]);
134161

content/dotnet-template-azure-iot-edge-module/FSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{
7878
"condition": "(target == 'deploy')",
7979
"exclude": [
80-
"*.cs", "*.csproj", ".gitignore"
80+
"*.fs", "*.fsproj", ".gitignore"
8181
]
8282
}
8383
]

0 commit comments

Comments
 (0)