Skip to content

Commit

Permalink
Cannot use full assembly path as dictionary key for execution options…
Browse files Browse the repository at this point in the history
… lookup, since .NET Core only passes the filename w/o path
  • Loading branch information
bradwilson committed May 10, 2024
1 parent c2f2d47 commit f497d65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public DefaultRunnerReporterMessageHandler(IRunnerLogger logger)
void AddExecutionOptions(string assemblyFilename, ITestFrameworkExecutionOptions executionOptions)
{
using (ReaderWriterLockWrapper.WriteLock())
executionOptionsByAssembly[assemblyFilename] = executionOptions;
executionOptionsByAssembly[Path.GetFileNameWithoutExtension(assemblyFilename)] = executionOptions;
}

/// <summary>
Expand Down Expand Up @@ -87,7 +87,7 @@ protected ITestFrameworkExecutionOptions GetExecutionOptions(string assemblyFile
ITestFrameworkExecutionOptions result;

using (ReaderWriterLockWrapper.ReadLock())
if (!executionOptionsByAssembly.TryGetValue(assemblyFilename, out result))
if (!executionOptionsByAssembly.TryGetValue(Path.GetFileNameWithoutExtension(assemblyFilename), out result))
result = defaultExecutionOptions;

return result;
Expand Down Expand Up @@ -149,7 +149,7 @@ protected virtual void LogOutput(StackFrameInfo frameInfo, string output)
void RemoveExecutionOptions(string assemblyFilename)
{
using (ReaderWriterLockWrapper.WriteLock())
executionOptionsByAssembly.Remove(assemblyFilename);
executionOptionsByAssembly.Remove(Path.GetFileNameWithoutExtension(assemblyFilename));
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public DefaultRunnerReporterWithTypesMessageHandler(IRunnerLogger logger)
void AddExecutionOptions(string assemblyFilename, ITestFrameworkExecutionOptions executionOptions)
{
using (ReaderWriterLockWrapper.WriteLock())
executionOptionsByAssembly[assemblyFilename] = executionOptions;
executionOptionsByAssembly[Path.GetFileNameWithoutExtension(assemblyFilename)] = executionOptions;
}

/// <summary>
Expand Down Expand Up @@ -101,7 +101,7 @@ protected ITestFrameworkExecutionOptions GetExecutionOptions(string assemblyFile
ITestFrameworkExecutionOptions result;

using (ReaderWriterLockWrapper.ReadLock())
if (!executionOptionsByAssembly.TryGetValue(assemblyFilename, out result))
if (!executionOptionsByAssembly.TryGetValue(Path.GetFileNameWithoutExtension(assemblyFilename), out result))
result = defaultExecutionOptions;

return result;
Expand Down Expand Up @@ -163,7 +163,7 @@ protected virtual void LogOutput(StackFrameInfo frameInfo, string output)
void RemoveExecutionOptions(string assemblyFilename)
{
using (ReaderWriterLockWrapper.WriteLock())
executionOptionsByAssembly.Remove(assemblyFilename);
executionOptionsByAssembly.Remove(Path.GetFileNameWithoutExtension(assemblyFilename));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ public class OnMessage_ITestOutput
[Fact]
public void WithoutFlag_LogsNothing()
{
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "assembly-path", showLiveOutput: false);
var outputMessage = Mocks.TestOutput("assembly-path", "test-name", "This is test output");
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "/path/to/assembly-path.dll", showLiveOutput: false);
var outputMessage = Mocks.TestOutput("assembly.DLL", "test-name", "This is test output");
var handler = TestableDefaultRunnerReporterMessageHandler.Create();

handler.OnMessage(executionStartingMessage);
Expand All @@ -265,8 +265,8 @@ public void WithoutFlag_LogsNothing()
[Fact]
public void WithFlag_LogsOutput()
{
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "assembly-path", showLiveOutput: true);
var outputMessage = Mocks.TestOutput("assembly-path", "test-name", "This is test output");
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "/path/to/assembly-path.dll", showLiveOutput: true);
var outputMessage = Mocks.TestOutput("assembly-path.DLL", "test-name", "This is test output");
var handler = TestableDefaultRunnerReporterMessageHandler.Create();

handler.OnMessage(executionStartingMessage);
Expand Down

0 comments on commit f497d65

Please sign in to comment.