Change IntegrationTestBase to properly locate baseline files in net451.
- Net451 tests would have their current directory set to the dll that was located in bin/debug/framework/rid/... when run via `dotnet test`. #885
This commit is contained in:
parent
853c28e568
commit
18bb31cee4
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
#if NET451
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
|
@ -18,6 +19,23 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
|
|||
[IntializeTestFile]
|
||||
public abstract class IntegrationTestBase
|
||||
{
|
||||
private static readonly string ThisProjectName = typeof(IntializeTestFileAttribute).GetTypeInfo().Assembly.GetName().Name;
|
||||
private static readonly string TestProjectRoot = FindTestProjectRoot();
|
||||
|
||||
private static string FindTestProjectRoot()
|
||||
{
|
||||
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
|
||||
while (currentDirectory != null &&
|
||||
!string.Equals(currentDirectory.Name, ThisProjectName, StringComparison.Ordinal))
|
||||
{
|
||||
currentDirectory = currentDirectory.Parent;
|
||||
}
|
||||
|
||||
var normalizedSeparators = currentDirectory.FullName.Replace(Path.DirectorySeparatorChar, '/');
|
||||
return currentDirectory.FullName;
|
||||
}
|
||||
|
||||
#if GENERATE_BASELINES
|
||||
private static readonly bool GenerateBaselines = true;
|
||||
#else
|
||||
|
|
@ -77,7 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
|
|||
|
||||
if (GenerateBaselines)
|
||||
{
|
||||
File.WriteAllText(baselineFilename, RazorIRNodeSerializer.Serialize(document));
|
||||
var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilename);
|
||||
File.WriteAllText(baselineFullPath, RazorIRNodeSerializer.Serialize(document));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue