File tree 2 files changed +71
-0
lines changed
2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ using Microsoft . Build . Framework ;
5
+ using Microsoft . Build . Utilities ;
6
+ using Moq ;
7
+ using System . Collections . Generic ;
8
+ using System . IO ;
9
+ using Xunit ;
10
+
11
+ namespace Microsoft . NET . Sdk . WebAssembly . Tests
12
+ {
13
+ public static class ConvertDllsToWebCilTests
14
+ {
15
+ private static ConvertDllsToWebCil task ;
16
+ private static List < BuildErrorEventArgs > errors ;
17
+
18
+ static ConvertDllsToWebCilTests ( )
19
+ {
20
+ task = new ConvertDllsToWebCil ( ) ;
21
+ var buildEngine = new Mock < IBuildEngine > ( ) ;
22
+ errors = new List < BuildErrorEventArgs > ( ) ;
23
+ buildEngine . Setup ( x => x . LogErrorEvent ( It . IsAny < BuildErrorEventArgs > ( ) ) ) . Callback < BuildErrorEventArgs > ( e => errors . Add ( e ) ) ;
24
+ task . BuildEngine = buildEngine . Object ;
25
+ }
26
+
27
+ [ Fact ]
28
+ public static void TestEmptyInput ( )
29
+ {
30
+ string input = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) + ".dll" ) ;
31
+
32
+ try
33
+ {
34
+ File . Create ( input ) . Dispose ( ) ;
35
+
36
+ task . Candidates = new ITaskItem [ ] { new TaskItem ( input ) } ;
37
+ task . IsEnabled = true ;
38
+ task . OutputPath = task . IntermediateOutputPath = Path . GetTempPath ( ) ;
39
+
40
+ bool result = task . Execute ( ) ;
41
+
42
+ Assert . False ( result ) ;
43
+ Assert . Single ( errors ) ;
44
+ Assert . Contains ( input , errors [ 0 ] . Message ) ;
45
+ }
46
+ finally
47
+ {
48
+ File . Delete ( input ) ;
49
+ }
50
+ }
51
+
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
+
3
+ <PropertyGroup >
4
+ <TargetFramework >$(NetCoreAppToolCurrent)</TargetFramework >
5
+ <Nullable >enable</Nullable >
6
+ <IsTestProject >true</IsTestProject >
7
+ </PropertyGroup >
8
+
9
+ <ItemGroup >
10
+ <PackageReference Include =" Microsoft.Build.Utilities.Core" Version =" $(MicrosoftBuildFrameworkVersion)" />
11
+ <PackageReference Include =" Moq" Version =" $(MoqVersion)" />
12
+ </ItemGroup >
13
+
14
+ <ItemGroup >
15
+ <ProjectReference Include =" ..\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj" />
16
+ </ItemGroup >
17
+
18
+ </Project >
You can’t perform that action at this time.
0 commit comments