Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/ScriptCs.Core/AssemblyUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@

namespace ScriptCs
{
using System.IO;

public class AssemblyUtility : IAssemblyUtility
{
public bool IsManagedAssembly(string path)
{
if (!Path.IsPathRooted(path) && !(path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)))
{
return true;
}

try
{
AssemblyName.GetAssemblyName(path);
Expand Down
33 changes: 33 additions & 0 deletions test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ScriptCs.Tests
{
using System.IO;
using Contracts;
using Xunit;
using Should;

public class AssemblyUtilityTests
{
public class TheIsManagedAssemblyMethod
{
private readonly IAssemblyUtility _assemblyUtility = new AssemblyUtility();

[Fact]
public void ShouldReturnTrueWhenThePathIsNotRootedAndDoesNotHaveADllOrExeExtension()
{
_assemblyUtility.IsManagedAssembly("System.Data").ShouldBeTrue();
}

[Fact]
public void ShouldReturnTrueWhenThePathPointsToAManagedAssembly()
{
_assemblyUtility.IsManagedAssembly(typeof(String).Assembly.Location).ShouldBeTrue();
}
}
}
}
1 change: 1 addition & 0 deletions test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</Compile>
<Compile Include="AppDomainAssemblyResolverTests.cs" />
<Compile Include="AssemblyResolverTests.cs" />
<Compile Include="AssemblyUtilityTests.cs" />
<Compile Include="DirectiveLineProcessorTests.cs" />
<Compile Include="FileSystemMigratorTests.cs" />
<Compile Include="PackageReferenceTests.cs" />
Expand Down