Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommandLineTool should accept DLL or EXE files regardless the extensi… #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Tests/JustAssembly.Tests/FileValidatorTests.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
5 changes: 5 additions & 0 deletions Tests/JustAssembly.Tests/JustAssembly.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</Compile>
<Compile Include="APIDiff\BaseExistingAPIDiffTestFixture.cs" />
<Compile Include="APIDiff\ExistingAPIDiffTestFixture.cs" />
<Compile Include="FileValidatorTests.cs" />
<Compile Include="SimpleTestClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -71,6 +72,10 @@
<Project>{d68133bd-1e63-496e-9ede-4fbdbf77b486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\..\UI\JustAssembly.CommandLineTool\JustAssembly.CommandLineTool.csproj">
<Project>{C6D6187D-CB83-40A1-A3F6-20FB9231D67B}</Project>
<Name>JustAssembly.CommandLineTool</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
11 changes: 4 additions & 7 deletions UI/JustAssembly.CommandLineTool/FilePathValidater.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace JustAssembly.CommandLineTool
{
Expand Down Expand Up @@ -27,12 +29,7 @@ private static bool ValidateFile(string filePath, List<string> validExtensions)
}

string extension = Path.GetExtension(filePath);
if (!validExtensions.Contains(extension))
{
return false;
}

return true;
return validExtensions.Any(x => x.Equals(extension,StringComparison.CurrentCultureIgnoreCase));
}
}
}
1 change: 1 addition & 0 deletions UI/JustAssembly.CommandLineTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c6d6187d-cb83-40a1-a3f6-20fb9231d67b")]
[assembly:InternalsVisibleTo("JustAssembly.Tests")]