diff --git a/Tests/JustAssembly.Tests/FileValidatorTests.cs b/Tests/JustAssembly.Tests/FileValidatorTests.cs new file mode 100644 index 0000000..6c481a0 --- /dev/null +++ b/Tests/JustAssembly.Tests/FileValidatorTests.cs @@ -0,0 +1,48 @@ + +using System; +using System.IO; +using JustAssembly.CommandLineTool; +using NUnit.Framework; + +namespace JustAssembly.Tests +{ + [TestFixture] + public class FileValidatorTests + { + [TestCase] + public void ExtensionsMustBeValid() + { + var fullFilename = EnsureFileExists("SomeFile.xml"); + + Assert.False(FilePathValidater.ValidateInputFile(fullFilename),"xml extension should not be accepted as valid"); + } + + + [TestCase] + public void HappyCase() + { + var fullFileName =EnsureFileExists("SomeFile.dll"); + Assert.True(FilePathValidater.ValidateInputFile(fullFileName),"dll should have been accepted"); + } + + [TestCase] + public void HappyCase_RegardlessExtensionCasing() + { + var fullFileName =EnsureFileExists("SomeFile.DLL"); + Assert.True(FilePathValidater.ValidateInputFile(fullFileName),"dll should have been accepted"); + } + + + + + private static string EnsureFileExists(string fileName) + { + var tempFolder = Path.GetTempPath(); + var folderName = Guid.NewGuid().ToString(); + var newFolder = Directory.CreateDirectory(folderName); + var fullFilename = Path.Combine(newFolder.FullName, fileName); + File.WriteAllText(fullFilename, string.Empty); + return fullFilename; + } + } +} diff --git a/Tests/JustAssembly.Tests/JustAssembly.Tests.csproj b/Tests/JustAssembly.Tests/JustAssembly.Tests.csproj index 85aea10..a247883 100644 --- a/Tests/JustAssembly.Tests/JustAssembly.Tests.csproj +++ b/Tests/JustAssembly.Tests/JustAssembly.Tests.csproj @@ -59,6 +59,7 @@ + @@ -71,6 +72,10 @@ {d68133bd-1e63-496e-9ede-4fbdbf77b486} Mono.Cecil + + {C6D6187D-CB83-40A1-A3F6-20FB9231D67B} + JustAssembly.CommandLineTool +