Skip to content

Commit b21cc65

Browse files
committed
Improved failure message and test
1 parent 2ce5c9d commit b21cc65

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Test/UnitTests/TestSupport/TestFileData.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System;
12
using System.Linq;
23
using System.Reflection;
4+
using Microsoft.EntityFrameworkCore;
35
using TestSupport.Helpers;
46
using Xunit.Extensions.AssertExtensions;
57
using Xunit;
@@ -20,6 +22,19 @@ public void TestGetCallerTopLevelDirectory()
2022
path.ShouldEndWith(this.GetType().Namespace.Split('.').First());
2123
}
2224

25+
26+
[Fact]
27+
public void TestGetCallerTopLevelDirectoryNuGetAssembly()
28+
{
29+
//SETUP
30+
31+
//ATTEMPT
32+
var ex = Assert.Throws<Exception>(() => TestData.GetCallingAssemblyTopLevelDir(Assembly.GetAssembly(typeof(DbContext))));
33+
34+
//VERIFY
35+
ex.Message.ShouldEqual(@"Did not find '\bin\' in the assembly. Do you need to provide the callingAssembly parameter?");
36+
}
37+
2338
[Fact]
2439
public void TestGetTestDataFileDirectory()
2540
{

TestSupport/Helpers/TestData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static string GetCallingAssemblyTopLevelDir(Assembly callingAssembly = nu
141141

142142
var indexOfPart = pathToManipulate.IndexOf(binDir, StringComparison.OrdinalIgnoreCase)+1;
143143
if (indexOfPart <= 0)
144-
throw new Exception($"Did not find '{binDir}' in the ApplicationBasePath");
144+
throw new Exception($"Did not find '{binDir}' in the assembly. Do you need to provide the callingAssembly parameter?");
145145

146146
return pathToManipulate.Substring(0, indexOfPart - 1);
147147
}

0 commit comments

Comments
 (0)