From 19c0e5c36b766a7260b07c7fb4f4984f3ede4e49 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Wed, 17 Apr 2024 00:19:26 -0600 Subject: [PATCH] add another test --- src/tasks/tests/ConvertDllsToWebCilTests.cs | 34 ++++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/tasks/tests/ConvertDllsToWebCilTests.cs b/src/tasks/tests/ConvertDllsToWebCilTests.cs index b497d410a435ef..c68dc6f21a38a5 100644 --- a/src/tasks/tests/ConvertDllsToWebCilTests.cs +++ b/src/tasks/tests/ConvertDllsToWebCilTests.cs @@ -10,12 +10,12 @@ namespace Microsoft.NET.Sdk.WebAssembly.Tests { - public static class ConvertDllsToWebCilTests + public class ConvertDllsToWebCilTests { - private static ConvertDllsToWebCil task; - private static List errors; + private ConvertDllsToWebCil task; + private List errors; - static ConvertDllsToWebCilTests() + public ConvertDllsToWebCilTests() { task = new ConvertDllsToWebCil(); var buildEngine = new Mock(); @@ -25,7 +25,7 @@ static ConvertDllsToWebCilTests() } [Fact] - public static void TestEmptyInput() + public void TestEmptyInput() { string input = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".dll"); @@ -49,5 +49,29 @@ public static void TestEmptyInput() } } + [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); + } + } } }