Skip to content

Commit

Permalink
Merge pull request #219 from hartmark/AssemblyLocationNamer
Browse files Browse the repository at this point in the history
Add new namer that looks for approval files in same folder as assembly
  • Loading branch information
isidore committed Mar 27, 2019
2 parents 53c5a7f + 9324e1a commit 5069f87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions ApprovalTests/Namers/AssemblyLocationNamer.cs
@@ -0,0 +1,23 @@
using System;
using System.IO;
using System.Reflection;

namespace ApprovalTests.Namers
{
public class AssemblyLocationNamer : UnitTestFrameworkNamer
{
private string AssemblyDirectory
{
get
{
// CodeBase is used because the NUnit test runner is otherwise quirky
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
var uri = new UriBuilder(codeBase);
var path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}

public override string SourcePath => AssemblyDirectory + GetSubdirectory();
}
}
2 changes: 1 addition & 1 deletion ApprovalTests/Namers/UnitTestFrameworkNamer.cs
Expand Up @@ -28,7 +28,7 @@ private void HandleSubdirectory()

public string Name => stackTraceParser.ApprovalName;

public string SourcePath => stackTraceParser.SourcePath + GetSubdirectory();
public virtual string SourcePath => stackTraceParser.SourcePath + GetSubdirectory();

public string GetSubdirectory()
{
Expand Down

0 comments on commit 5069f87

Please sign in to comment.