10
10
11
11
namespace Microsoft . NET . Sdk . WebAssembly . Tests
12
12
{
13
- public static class ConvertDllsToWebCilTests
13
+ public class ConvertDllsToWebCilTests
14
14
{
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 > ( ) ;
17
17
18
- static ConvertDllsToWebCilTests ( )
18
+ public ConvertDllsToWebCilTests ( )
19
19
{
20
- task = new ConvertDllsToWebCil ( ) ;
21
20
var buildEngine = new Mock < IBuildEngine > ( ) ;
22
- errors = new List < BuildErrorEventArgs > ( ) ;
23
21
buildEngine . Setup ( x => x . LogErrorEvent ( It . IsAny < BuildErrorEventArgs > ( ) ) ) . Callback < BuildErrorEventArgs > ( e => errors . Add ( e ) ) ;
24
22
task . BuildEngine = buildEngine . Object ;
25
23
}
26
24
27
25
[ Fact ]
28
- public static void TestEmptyInput ( )
26
+ public void TestEmptyInput ( )
29
27
{
30
28
string input = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) + ".dll" ) ;
31
29
@@ -49,5 +47,29 @@ public static void TestEmptyInput()
49
47
}
50
48
}
51
49
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
+ }
52
74
}
53
75
}
0 commit comments