Skip to content

Commit fef5930

Browse files
committed
Fix bug in test setup for DirectoryLocator
1 parent 802484b commit fef5930

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Src/Axuno.VirtualFileSystem.Tests/DirectoryLocator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static string GetTargetProjectPath(Type classFromTargetAssembly)
1616
var targetAssembly = classFromTargetAssembly.GetTypeInfo().Assembly;
1717

1818
// Get name of the target project which we want to test
19-
var projectName = targetAssembly.GetName().Name;
19+
var projectName = targetAssembly.GetName().Name ?? throw new Exception("Assembly name is null");
2020

2121
// Get currently executing test project path
2222
var applicationBasePath = AppContext.BaseDirectory;
@@ -26,6 +26,7 @@ public static string GetTargetProjectPath(Type classFromTargetAssembly)
2626
do
2727
{
2828
directoryInfo = directoryInfo.Parent;
29+
if (directoryInfo == null) break;
2930

3031
var projectDirectoryInfo = new DirectoryInfo(directoryInfo.FullName);
3132
if (projectDirectoryInfo.Exists)
@@ -37,9 +38,10 @@ public static string GetTargetProjectPath(Type classFromTargetAssembly)
3738
}
3839
}
3940
}
40-
while (directoryInfo.Parent != null || directoryInfo.Parent.FullName.EndsWith("\\" + projectName));
41+
while (directoryInfo.Parent != null);
4142

4243
throw new Exception($"Project root could not be located using the application root {applicationBasePath}.");
4344
}
4445
}
46+
4547
}

0 commit comments

Comments
 (0)