Resharper - NUnit - 无法 运行 单元测试,因为代码和测试项目二进制文件位于不同位置

Resharper - NUnit - unable to run unit tests because code and test project binaries in different locations

我的解决方案中有 2 个项目,一个是实际代码 (NUnitSample1),另一个是测试项目 (NUnitSample1.Test) 与单元测试。 NUnitSample1.Test 包含第一个项目 NUnitSample1 的引用。两个项目的生成输出路径不同,并且已明确指定。 NUnitSample1项目引用的CopyLocal属性需要设置为false.

现在,当我使用 ReSharper 构建并尝试 运行 单元测试时,它失败并显示以下消息:

System.IO.FileNotFoundException : Could not load file or assembly 'NUnitSample1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

我想这是因为二进制文件位于不同的文件夹中。有什么方法可以 运行 在维护此结构的同时使用 ReSharper 进行测试吗?此外,已经编写了数万个测试,因此我需要一个涉及最少代码更改的解决方案。动态加载程序集(如 AlexeiLevenkov 所建议的那样)可行,但是,这将涉及单独设置每个方法,这是不可行的。

+NUnitSample1Solution
 +NUnitSample1      //This folder contains the actual class library project
 +NUnitSample1.Test //This folder contains the test project
 +Binaries          //This folder contains the binaries of both projects
  +bin              //This folder contains the project dll
  +tests
   +bin             //This folder contains the test project dll

我发现这个 NUnit link 可以指定多个程序集,但是,当我尝试 运行 使用 ReSharper 时,即使这样也不起作用。我也不确定我是否做对了,配置文件需要添加到哪里?在实际项目中还是在测试项目中?构建操作应该是什么?

如有任何指点,我们将不胜感激。 TIA.

我能够使用 TestFixtureSetuphere 的答案加载丢失的程序集(也将在 Setup 方法中工作)。

[TestFixtureSetUp]
public void Setup()
{
    AppDomain currentDomain = AppDomain.CurrentDomain;
    currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromSameFolder);
}

static Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
{
    string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");           
    if (File.Exists(assemblyPath) == false) return null;
    Assembly assembly = Assembly.LoadFrom(assemblyPath);
    return assembly;
}

可以修改 LoadFromSameFolder 方法中的上述代码以准确定位程序集。

PS:感谢 Alexei Levenkov 让我走上了正确的道路。