Skip to content

Commit fafc902

Browse files
committed
add another test
1 parent ac61c3a commit fafc902

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/tasks/tests/ConvertDllsToWebCilTests.cs

+29-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@
1010

1111
namespace Microsoft.NET.Sdk.WebAssembly.Tests
1212
{
13-
public static class ConvertDllsToWebCilTests
13+
public class ConvertDllsToWebCilTests
1414
{
15-
private static ConvertDllsToWebCil task;
16-
private static List<BuildErrorEventArgs> errors;
15+
private ConvertDllsToWebCil task = new ConvertDllsToWebCil();
16+
private List<BuildErrorEventArgs> errors = new List<BuildErrorEventArgs>();
1717

18-
static ConvertDllsToWebCilTests()
18+
public ConvertDllsToWebCilTests()
1919
{
20-
task = new ConvertDllsToWebCil();
2120
var buildEngine = new Mock<IBuildEngine>();
22-
errors = new List<BuildErrorEventArgs>();
2321
buildEngine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback<BuildErrorEventArgs>(e => errors.Add(e));
2422
task.BuildEngine = buildEngine.Object;
2523
}
2624

2725
[Fact]
28-
public static void TestEmptyInput()
26+
public void TestEmptyInput()
2927
{
3028
string input = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".dll");
3129

@@ -49,5 +47,29 @@ public static void TestEmptyInput()
4947
}
5048
}
5149

50+
[Fact]
51+
public void TestInvalidDirectoryInput()
52+
{
53+
string input = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".dll");
54+
55+
try
56+
{
57+
Directory.CreateDirectory(input);
58+
59+
task.Candidates = new ITaskItem[] { new TaskItem(input) };
60+
task.IsEnabled = true;
61+
task.OutputPath = task.IntermediateOutputPath = Path.GetTempPath();
62+
63+
bool result = task.Execute();
64+
65+
Assert.False(result);
66+
Assert.Single(errors);
67+
Assert.Contains(input, errors[0].Message);
68+
}
69+
finally
70+
{
71+
Directory.Delete(input);
72+
}
73+
}
5274
}
5375
}

0 commit comments

Comments
 (0)