WebJobsCommandGeneratorTests.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. using Microsoft.NET.Sdk.Publish.Tasks;
  4. namespace Microsoft.Net.Sdk.Publish.Tasks.Tests
  5. {
  6. public class WebJobsCommandGeneratorTests
  7. {
  8. [Theory]
  9. // Windows
  10. [InlineData("c:/test/WebApplication1.dll", false, ".exe", "dotnet WebApplication1.dll %*")]
  11. [InlineData("c:/test/WebApplication1.dll", true, ".exe", "WebApplication1.exe %*")]
  12. [InlineData("c:/test/WebApplication1.dll", true, "", "WebApplication1 %*")]
  13. [InlineData("c:/test/WebApplication1.exe", true, ".exe", "WebApplication1.exe %*")]
  14. [InlineData("c:/test/WebApplication1.exe", false, ".exe", "WebApplication1.exe %*")]
  15. [InlineData("/usr/test/WebApplication1.dll", true, ".sh", "WebApplication1.sh %*")]
  16. [InlineData("/usr/test/WebApplication1.dll", false, ".sh", "dotnet WebApplication1.dll %*")]
  17. //Linux
  18. [InlineData("c:/test/WebApplication1.dll", false, "", "#!/bin/bash\ndotnet WebApplication1.dll \"$@\"", true)]
  19. [InlineData("c:/test/WebApplication1.dll", true, "", "#!/bin/bash\n. WebApplication1 \"$@\"", true)]
  20. [InlineData("/usr/test/WebApplication1.dll", false, ".sh", "#!/bin/bash\ndotnet WebApplication1.dll \"$@\"", true)]
  21. [InlineData("/usr/test/WebApplication1.dll", true, ".sh", "#!/bin/bash\n. WebApplication1.sh \"$@\"", true)]
  22. public void WebJobsCommandGenerator_Generates_Correct_RunCmd(string targetPath, bool useAppHost, string executableExtension, string expected, bool isLinux = false)
  23. {
  24. // Arrange
  25. // Test
  26. string generatedRunCommand = WebJobsCommandGenerator.RunCommand(targetPath, useAppHost, executableExtension, isLinux);
  27. // Assert
  28. Assert.Equal(expected, generatedRunCommand);
  29. }
  30. }
  31. }