forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d42fec
commit 9d15d5d
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using Moq; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace Microsoft.NET.Sdk.WebAssembly.Tests | ||
{ | ||
public class ConvertDllsToWebCilTests | ||
{ | ||
private ConvertDllsToWebCil task = new ConvertDllsToWebCil(); | ||
private List<BuildErrorEventArgs> errors = new List<BuildErrorEventArgs>(); | ||
|
||
public ConvertDllsToWebCilTests() | ||
{ | ||
var buildEngine = new Mock<IBuildEngine>(); | ||
buildEngine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback<BuildErrorEventArgs>(e => errors.Add(e)); | ||
task.BuildEngine = buildEngine.Object; | ||
} | ||
|
||
[Fact] | ||
public void TestEmptyInput() | ||
{ | ||
string input = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".dll"); | ||
|
||
try | ||
{ | ||
File.Create(input).Dispose(); | ||
|
||
task.Candidates = new ITaskItem[] { new TaskItem(input) }; | ||
task.IsEnabled = true; | ||
task.OutputPath = task.IntermediateOutputPath = Path.GetTempPath(); | ||
|
||
bool result = task.Execute(); | ||
|
||
Assert.False(result); | ||
Assert.Single(errors); | ||
Assert.Contains(input, errors[0].Message); | ||
} | ||
finally | ||
{ | ||
File.Delete(input); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestInvalidDirectoryInput() | ||
{ | ||
string input = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".dll"); | ||
|
||
try | ||
{ | ||
Directory.CreateDirectory(input); | ||
|
||
task.Candidates = new ITaskItem[] { new TaskItem(input) }; | ||
task.IsEnabled = true; | ||
task.OutputPath = task.IntermediateOutputPath = Path.GetTempPath(); | ||
|
||
bool result = task.Execute(); | ||
|
||
Assert.False(result); | ||
Assert.Single(errors); | ||
Assert.Contains(input, errors[0].Message); | ||
} | ||
finally | ||
{ | ||
Directory.Delete(input); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/tasks/tests/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildFrameworkVersion)" /> | ||
<PackageReference Include="Moq" Version="$(MoqVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.11.34815.271 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.Tests", "Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.Tests.csproj", "{035240F3-31CE-409E-8D55-2A89ADE522D6}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.WebAssembly.Pack.Tasks", "..\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj", "{4C68406D-BBFC-4637-A634-917C0621A883}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{035240F3-31CE-409E-8D55-2A89ADE522D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{035240F3-31CE-409E-8D55-2A89ADE522D6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{035240F3-31CE-409E-8D55-2A89ADE522D6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{035240F3-31CE-409E-8D55-2A89ADE522D6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4C68406D-BBFC-4637-A634-917C0621A883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4C68406D-BBFC-4637-A634-917C0621A883}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4C68406D-BBFC-4637-A634-917C0621A883}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4C68406D-BBFC-4637-A634-917C0621A883}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {15EFCF6A-C86C-474F-BBAD-F2DB4B3DBAA3} | ||
EndGlobalSection | ||
EndGlobal |