diff --git a/ILMerge.Tests/BaselineTests.cs b/ILMerge.Tests/BaselineTests.cs index 156c3b0..97e2888 100644 --- a/ILMerge.Tests/BaselineTests.cs +++ b/ILMerge.Tests/BaselineTests.cs @@ -1,8 +1,11 @@ using System.Reflection; using NUnit.Framework; +using TestTools; +using System.Diagnostics.CodeAnalysis; namespace ILMerging.Tests { + [ExcludeFromCodeCoverage] [TestFixture] public sealed class BaselineTests { diff --git a/ILMerge.Tests/ILMerge.Tests.csproj b/ILMerge.Tests/ILMerge.Tests.csproj index 0b292f2..a3f62b2 100644 --- a/ILMerge.Tests/ILMerge.Tests.csproj +++ b/ILMerge.Tests/ILMerge.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/ILMerge.Tests/Integration/ConsoleTests.cs b/ILMerge.Tests/Integration/ConsoleTests.cs index d453774..5772ab0 100644 --- a/ILMerge.Tests/Integration/ConsoleTests.cs +++ b/ILMerge.Tests/Integration/ConsoleTests.cs @@ -3,11 +3,13 @@ using System.IO; using System.Reflection; using System.Runtime.InteropServices; -using ILMerging.Tests.Helpers; +using TestTools.Helpers; using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; namespace ILMerging.Tests.Integration { + [ExcludeFromCodeCoverage] [TestFixture, Category("Integration")] public sealed class ConsoleTests { diff --git a/ILMerge.Tests/KeyTests.cs b/ILMerge.Tests/KeyTests.cs index dc4e965..592b0cb 100644 --- a/ILMerge.Tests/KeyTests.cs +++ b/ILMerge.Tests/KeyTests.cs @@ -2,11 +2,14 @@ using System.IO; using System.Reflection; using System.Security.Cryptography; -using ILMerging.Tests.Helpers; +using TestTools.Helpers; +using TestTools; using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; namespace ILMerging.Tests { + [ExcludeFromCodeCoverage] [TestFixture] public sealed class KeyTests { diff --git a/ILMerge.Tests/TestFiles.cs b/ILMerge.Tests/TestFiles.cs index 07d00e8..86eb935 100644 --- a/ILMerge.Tests/TestFiles.cs +++ b/ILMerge.Tests/TestFiles.cs @@ -1,8 +1,10 @@ using System.IO; using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; namespace ILMerging.Tests { + [ExcludeFromCodeCoverage] internal static class TestFiles { private static string FromCurrentDir(string fileName) diff --git a/ILMerge.sln b/ILMerge.sln index 6b839f6..2960ac1 100644 --- a/ILMerge.sln +++ b/ILMerge.sln @@ -1,12 +1,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILMerge", "ILMerge\ILMerge.csproj", "{84B41834-EFDE-4E52-A8CE-B51DFCB1D1B2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILMerge", "ILMerge\ILMerge.csproj", "{84B41834-EFDE-4E52-A8CE-B51DFCB1D1B2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Compiler", "System.Compiler\System.Compiler.csproj", "{D7E16B38-3893-4EEF-847F-A3BE807E9546}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILMerge.Tests", "ILMerge.Tests\ILMerge.Tests.csproj", "{734805E8-B2FB-41E3-A669-80429AA50C98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILMerge.Tests", "ILMerge.Tests\ILMerge.Tests.csproj", "{734805E8-B2FB-41E3-A669-80429AA50C98}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2EC5A7D-1059-4EC6-95FB-B2075609DF4B}" ProjectSection(SolutionItems) = preProject @@ -14,6 +14,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILMergeMsTest.UnitTests", "ILMergeMsTest.UnitTests\ILMergeMsTest.UnitTests.csproj", "{E75D1760-E327-4709-892E-8CF522CACADB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTools", "TestTools\TestTools.csproj", "{E0F0B234-A11A-43DC-9461-3B0184FA5E90}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,6 +36,14 @@ Global {734805E8-B2FB-41E3-A669-80429AA50C98}.Debug|Any CPU.Build.0 = Debug|Any CPU {734805E8-B2FB-41E3-A669-80429AA50C98}.Release|Any CPU.ActiveCfg = Release|Any CPU {734805E8-B2FB-41E3-A669-80429AA50C98}.Release|Any CPU.Build.0 = Release|Any CPU + {E75D1760-E327-4709-892E-8CF522CACADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E75D1760-E327-4709-892E-8CF522CACADB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E75D1760-E327-4709-892E-8CF522CACADB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E75D1760-E327-4709-892E-8CF522CACADB}.Release|Any CPU.Build.0 = Release|Any CPU + {E0F0B234-A11A-43DC-9461-3B0184FA5E90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0F0B234-A11A-43DC-9461-3B0184FA5E90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0F0B234-A11A-43DC-9461-3B0184FA5E90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0F0B234-A11A-43DC-9461-3B0184FA5E90}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ILMergeMsTest.UnitTests/BaselineMSTests.cs b/ILMergeMsTest.UnitTests/BaselineMSTests.cs new file mode 100644 index 0000000..1683618 --- /dev/null +++ b/ILMergeMsTest.UnitTests/BaselineMSTests.cs @@ -0,0 +1,37 @@ +using ILMerging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using TestTools; + +namespace ILMergeMsTest.UnitTests +{ + [ExcludeFromCodeCoverage] + [TestClass] + public sealed class BaselineMSTests + { + #region Private Members + private const string Extension = ".dll"; + private const string TestSnk = "test.snk"; + private const string TestPfx = "test.pfx"; + #endregion + + #region Public Properties + public TestContext TestContext { get; set; } + #endregion + + /// + /// Replicating the "Single_Input" NUnit test, using MSTest2. + /// Test output and working directory is within the generated "TestResults" folder - it is cleansed for all "Release" test runs, + /// and partially persists for "Debug" test runs (the NUnit tests are using the system's "Temp" directory, which is not preferable). + /// + /// + [TestMethod] + public void Single_input() + { + var ilMerge = new ILMerge(); + ilMerge.SetUpInputAssemblyForTest(Assembly.GetExecutingAssembly()); + ilMerge.MergeToTempFileForTest(".dll"); + } + } +} diff --git a/ILMergeMsTest.UnitTests/ConsoleMSTests.cs b/ILMergeMsTest.UnitTests/ConsoleMSTests.cs new file mode 100644 index 0000000..d7b3ae6 --- /dev/null +++ b/ILMergeMsTest.UnitTests/ConsoleMSTests.cs @@ -0,0 +1,80 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using TestTools.Helpers; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ILMerging; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace ILMergeMsTest.UnitTests +{ + [ExcludeFromCodeCoverage] + [TestClass] + public sealed class ConsoleMSTests + { + #region Private Members + private const string Extension = ".dll"; + private const string TestSnk = "test.snk"; + private const string TestPfx = "test.pfx"; + #endregion + + #region Public Properties + public TestContext TestContext { get; set; } + #endregion + + /// + /// Demonstrating MSTest2 DataRowAttribute usage, + /// that partially replicates nUnit TestFixture and TestCase functionality. + /// Test output and working directory is within the generated "TestResults" folder - it is cleansed for all "Release" test runs, + /// and partially persists for "Debug" test runs (the NUnit tests are using the system's "Temp" directory, which is not preferable). + /// + /// + [TestMethod] + [TestCategory("Integration")] + [DeploymentItem("TestData")] + [DataRow(true, DisplayName = "(with mscorsn in path)")] + [DataRow(false, DisplayName = "(without mscorsn in path)")] + public void No_DLL_load_crashes_when_given_PFX(bool withMscorsnInPath) + { + // Inconclusive for non-64 Bit OS' + if (withMscorsnInPath && !Environment.Is64BitOperatingSystem) Assert.Inconclusive("This test can only be run on a 64-bit OS."); + + // ARRANGE + var ilMergeExePath = typeof(ILMerge).Assembly.Location; + var inputAssembly = Assembly.GetExecutingAssembly(); + var fileName = ShadowCopyUtils.GenerateILMergeLibCliSwitches(inputAssembly); + var outputFile = Path.Combine(TestContext.DeploymentDirectory, + Path.ChangeExtension(Path.GetRandomFileName(), Extension)); + + var startInfo = new ProcessStartInfo( + ilMergeExePath, $"{fileName} /keyfile:\"{TestPfx}\" /out:\"{outputFile}\" \"{inputAssembly.Location}\"") + { + WorkingDirectory = Path.GetDirectoryName(inputAssembly.Location) + }; + + if (withMscorsnInPath) + { + startInfo.EnvironmentVariables["PATH"] = $"{Environment.GetEnvironmentVariable("PATH")};{RuntimeEnvironment.GetRuntimeDirectory()}"; + } + + // ACT + // The system runs .NET executables as 64-bit no matter what the architecture of the calling process is. + var result = ProcessUtils.Run(startInfo); + + // ASSERT + Assert.AreEqual(0, result.ExitCode); + Assert.IsFalse(result.ToString().Contains("Unable to load DLL 'mscorsn.dll'")); + Assert.IsFalse(result.ToString().Contains("An attempt was made to load a program with an incorrect format.")); + + // Test failures: + Assert.IsFalse(result.ToString().Contains("Unhandled Exception: System.IO.FileNotFoundException"), + "The test is not being run properly. If you are using ReSharper, disable shadow copy. " + + "If you are using NCrunch, go to NCrunch's configuration for the ILMerge project and " + + "make sure \"Copy referenced assemblies to workspace\" is set to True. " + + "(Both ReSharper and NCrunch settings are saved in the repo, so this should not happen.)"); + } + } +} diff --git a/ILMergeMsTest.UnitTests/ILMergeMsTest.UnitTests.csproj b/ILMergeMsTest.UnitTests/ILMergeMsTest.UnitTests.csproj new file mode 100644 index 0000000..7a8a641 --- /dev/null +++ b/ILMergeMsTest.UnitTests/ILMergeMsTest.UnitTests.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {E75D1760-E327-4709-892E-8CF522CACADB} + Library + Properties + ILMergeMsTest.UnitTests + ILMergeMsTest.UnitTests + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + {84b41834-efde-4e52-a8ce-b51dfcb1d1b2} + ILMerge + + + {e0f0b234-a11a-43dc-9461-3b0184fa5e90} + TestTools + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/ILMergeMsTest.UnitTests/KeyMSTests.cs b/ILMergeMsTest.UnitTests/KeyMSTests.cs new file mode 100644 index 0000000..f0704cf --- /dev/null +++ b/ILMergeMsTest.UnitTests/KeyMSTests.cs @@ -0,0 +1,125 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.IO; +using ILMerging; +using System.Reflection; +using TestTools.Helpers; +using TestTools; +using System.Security.Cryptography; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace ILMergeMsTest.UnitTests +{ + /// + /// The purpose of this class is to demonstrate that MSTest/MSTest2 is just as simple to use as nUnit. + /// MSTest and NUnit both have their own strengths and weaknesses, but for the most part - these tests are simple. + /// Test output and working directory is within the generated "TestResults" folder - it is cleansed for all "Release" test runs, + /// and partially persists for "Debug" test runs (the NUnit tests are using the system's "Temp" directory, which is not preferable). + /// + [ExcludeFromCodeCoverage] + [TestClass] + public sealed class KeyMSTests + { + #region Private Members + private const string Extension = ".dll"; + private const string TestSnk = "test.snk"; + private const string TestPfx = "test.pfx"; + private static List _keyContainerNameList = new List(); + #endregion + + #region Public Properties + public TestContext TestContext { get; set; } + #endregion + + #region Init and Cleanup + /// + /// Let's cleanup Csp Containers after all tests have executed (successfully or unsuccessfully). + /// + [ClassCleanup] + public static void ClassCleanup() + { + _keyContainerNameList.ForEach(containerName => CspContainerUtils.Delete(true, containerName, KeyNumber.Signature)); + } + #endregion + + [TestMethod] + [DeploymentItem("TestData")] + public void Can_sign_using_keyfile() + { + // ARRANGE + var outputFile = Path.Combine(TestContext.DeploymentDirectory, + Path.ChangeExtension(Path.GetRandomFileName(), Extension)); + + var ilMerge = new ILMerge { KeyFile = "test.snk", OutputFile = outputFile }; + + ilMerge.SetUpInputAssemblyForTest(Assembly.GetExecutingAssembly()); + + // ACT + ilMerge.Merge(); + + // ASSERT + var expectedKeyBytes = new StrongNameKeyPair(File.ReadAllBytes(TestSnk)).PublicKey; + var outputFileKeyBytes = AssemblyName.GetAssemblyName(outputFile).GetPublicKey(); + CollectionAssert.AreEqual(expectedKeyBytes, outputFileKeyBytes, "Expected PublicKey bytes do not match-up to the generated assembly PublicKey bytes"); + } + + [TestMethod] + [DeploymentItem("TestData")] + public void Can_sign_using_keycontainer() + { + // ARRANGE + var keyContainerName = Guid.NewGuid().ToString(); + _keyContainerNameList.Add(keyContainerName); + + CspContainerUtils.ImportBlob(true, keyContainerName, KeyNumber.Signature, File.ReadAllBytes(TestSnk)); + + var outputFile = Path.Combine(TestContext.DeploymentDirectory, + Path.ChangeExtension(Path.GetRandomFileName(), Extension)); + + var ilMerge = new ILMerge + { + KeyContainer = keyContainerName, + OutputFile = outputFile + }; + ilMerge.SetUpInputAssemblyForTest(Assembly.GetExecutingAssembly()); + + // ACT + ilMerge.Merge(); + + // ASSERT + var expectedKeyBytes = new StrongNameKeyPair(File.ReadAllBytes(TestSnk)).PublicKey; + var outputFileKeyBytes = AssemblyName.GetAssemblyName(outputFile).GetPublicKey(); + CollectionAssert.AreEqual(expectedKeyBytes, outputFileKeyBytes, "Expected PublicKey bytes do not match-up to the generated assembly PublicKey bytes"); + } + + [TestMethod] + [DeploymentItem("TestData")] + public void Bad_keyfile_gives_diagnostic_warning() + { + // ARRANGE + var outputFile = Path.Combine(TestContext.DeploymentDirectory, + Path.ChangeExtension(Path.GetRandomFileName(), Extension)); + + var logFile = Path.Combine(TestContext.DeploymentDirectory, + Path.ChangeExtension(Path.GetRandomFileName(), ".log")); + + var ilMerge = new ILMerge + { + KeyFile = TestPfx, + OutputFile = outputFile, + LogFile = logFile + }; + ilMerge.SetUpInputAssemblyForTest(Assembly.GetExecutingAssembly()); + + //ACT + ilMerge.Merge(); + + //ASSERT + var logText = File.ReadAllText(logFile); + Assert.IsTrue(logText.Contains("Unable to obtain public key for StrongNameKeyPair.")); + Assert.IsTrue(logText.Contains("PFX")); + Assert.IsTrue(logText.Contains("key container")); + } + } +} diff --git a/ILMergeMsTest.UnitTests/Properties/AssemblyInfo.cs b/ILMergeMsTest.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b6b9dd --- /dev/null +++ b/ILMergeMsTest.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("ILMergeMsTest.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ILMergeMsTest.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("e75d1760-e327-4709-892e-8cf522cacadb")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ILMergeMsTest.UnitTests/Readme.txt b/ILMergeMsTest.UnitTests/Readme.txt new file mode 100644 index 0000000..2dcabeb --- /dev/null +++ b/ILMergeMsTest.UnitTests/Readme.txt @@ -0,0 +1,17 @@ +The purpose of this unit test project is to demonstrate that MSTest2 unit tests are very similar to nUnit tests. +Both frameworks have their strengths and weaknesses - but I prefer MSTest2 :). + +I do appreciate nUnit's TestFixture, and TestClass functionality - + I think MSTest2 can provide the same benefits; in some cases in a simpler manner, other cases... not so simple. + +With MSTest2 we can use the DataRow attribute, which is similar to nUnit's TestCase attribute - to provide data-driven unit test processing. + +nUnit example: + [TestCase(true, TestName = "{m}(with mscorsn in path)")] + [TestCase(false, TestName = "{m}(without mscorsn in path)")] + public void No_DLL_load_crashes_when_given_PFX(bool withMscorsnInPath) + +MSTest2 example: + [DataRow(true, DisplayName = "(with mscorsn in path)")] + [DataRow(false, DisplayName = "(without mscorsn in path)")] + public void No_DLL_load_crashes_when_given_PFX(bool withMscorsnInPath) \ No newline at end of file diff --git a/ILMergeMsTest.UnitTests/TestData/test.pfx b/ILMergeMsTest.UnitTests/TestData/test.pfx new file mode 100644 index 0000000..99aa269 Binary files /dev/null and b/ILMergeMsTest.UnitTests/TestData/test.pfx differ diff --git a/ILMergeMsTest.UnitTests/TestData/test.snk b/ILMergeMsTest.UnitTests/TestData/test.snk new file mode 100644 index 0000000..482d44e Binary files /dev/null and b/ILMergeMsTest.UnitTests/TestData/test.snk differ diff --git a/ILMergeMsTest.UnitTests/packages.config b/ILMergeMsTest.UnitTests/packages.config new file mode 100644 index 0000000..5304c05 --- /dev/null +++ b/ILMergeMsTest.UnitTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ILMerge.Tests/Extensions.cs b/TestTools/Extensions.cs similarity index 81% rename from ILMerge.Tests/Extensions.cs rename to TestTools/Extensions.cs index 7e2cf8b..c57b3ad 100644 --- a/ILMerge.Tests/Extensions.cs +++ b/TestTools/Extensions.cs @@ -1,9 +1,12 @@ -using System.Linq; +using ILMerging; +using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Reflection; -using ILMerging.Tests.Helpers; +using TestTools.Helpers; -namespace ILMerging.Tests +namespace TestTools { + [ExcludeFromCodeCoverage] internal static class Extensions { public static void SetUpInputAssemblyForTest(this ILMerge ilMerge, Assembly inputAssembly) diff --git a/ILMerge.Tests/Helpers/CspContainerUtils.cs b/TestTools/Helpers/CspContainerUtils.cs similarity index 92% rename from ILMerge.Tests/Helpers/CspContainerUtils.cs rename to TestTools/Helpers/CspContainerUtils.cs index 6fef286..ec86a9c 100644 --- a/ILMerge.Tests/Helpers/CspContainerUtils.cs +++ b/TestTools/Helpers/CspContainerUtils.cs @@ -1,7 +1,9 @@ -using System.Security.Cryptography; +using System.Diagnostics.CodeAnalysis; +using System.Security.Cryptography; -namespace ILMerging.Tests.Helpers +namespace TestTools.Helpers { + [ExcludeFromCodeCoverage] public static class CspContainerUtils { public static void ImportBlob(bool machineLevel, string containerName, KeyNumber keyNumber, byte[] blob) diff --git a/ILMerge.Tests/Helpers/ProcessUtils.cs b/TestTools/Helpers/ProcessUtils.cs similarity index 97% rename from ILMerge.Tests/Helpers/ProcessUtils.cs rename to TestTools/Helpers/ProcessUtils.cs index 3b789be..fe4f022 100644 --- a/ILMerge.Tests/Helpers/ProcessUtils.cs +++ b/TestTools/Helpers/ProcessUtils.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Text; -namespace ILMerging.Tests.Helpers +namespace TestTools.Helpers { + [ExcludeFromCodeCoverage] public static class ProcessUtils { public static ProcessResult Run(ProcessStartInfo startInfo) diff --git a/ILMerge.Tests/Helpers/ShadowCopyUtils.cs b/TestTools/Helpers/ShadowCopyUtils.cs similarity index 94% rename from ILMerge.Tests/Helpers/ShadowCopyUtils.cs rename to TestTools/Helpers/ShadowCopyUtils.cs index 18769ce..5d9a1fb 100644 --- a/ILMerge.Tests/Helpers/ShadowCopyUtils.cs +++ b/TestTools/Helpers/ShadowCopyUtils.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; -namespace ILMerging.Tests.Helpers +namespace TestTools.Helpers { + [ExcludeFromCodeCoverage] public static class ShadowCopyUtils { public static IEnumerable GetTransitiveClosure(params Assembly[] assemblies) diff --git a/ILMerge.Tests/Helpers/StackEnumerator.cs b/TestTools/Helpers/StackEnumerator.cs similarity index 97% rename from ILMerge.Tests/Helpers/StackEnumerator.cs rename to TestTools/Helpers/StackEnumerator.cs index 460822d..89323a8 100644 --- a/ILMerge.Tests/Helpers/StackEnumerator.cs +++ b/TestTools/Helpers/StackEnumerator.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; -namespace ILMerging.Tests.Helpers +namespace TestTools.Helpers { + [ExcludeFromCodeCoverage] public static class StackEnumerator { public static StackEnumerator Create(params T[] initial) => new StackEnumerator(initial); @@ -14,6 +16,7 @@ public static class StackEnumerator public static StackEnumerator Create(TContext initialContext, IEnumerator initial) => new StackEnumerator(initialContext, initial); } + [ExcludeFromCodeCoverage] public sealed class StackEnumerator : IDisposable { private readonly Stack> stack = new Stack>(); @@ -76,6 +79,7 @@ public void Dispose() } } + [ExcludeFromCodeCoverage] public sealed class StackEnumerator : IDisposable { public struct ContextCurrent diff --git a/ILMerge.Tests/Helpers/TempFile.cs b/TestTools/Helpers/TempFile.cs similarity index 91% rename from ILMerge.Tests/Helpers/TempFile.cs rename to TestTools/Helpers/TempFile.cs index 2df1d48..cdb0022 100644 --- a/ILMerge.Tests/Helpers/TempFile.cs +++ b/TestTools/Helpers/TempFile.cs @@ -1,10 +1,12 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Threading; -namespace ILMerging.Tests.Helpers +namespace TestTools.Helpers { + [ExcludeFromCodeCoverage] [DebuggerDisplay("{ToString(),nq}")] public sealed class TempFile : IDisposable { diff --git a/TestTools/Properties/AssemblyInfo.cs b/TestTools/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e105234 --- /dev/null +++ b/TestTools/Properties/AssemblyInfo.cs @@ -0,0 +1,39 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestTools")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TestTools")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e0f0b234-a11a-43dc-9461-3b0184fa5e90")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: InternalsVisibleTo("ILMergeMsTest.UnitTests")] +[assembly: InternalsVisibleTo("ILMerge.Tests")] diff --git a/TestTools/TestTools.csproj b/TestTools/TestTools.csproj new file mode 100644 index 0000000..60c6acd --- /dev/null +++ b/TestTools/TestTools.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {E0F0B234-A11A-43DC-9461-3B0184FA5E90} + Library + Properties + TestTools + TestTools + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + {84b41834-efde-4e52-a8ce-b51dfcb1d1b2} + ILMerge + + + + \ No newline at end of file