Skip to content

Commit

Permalink
better debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-hammant committed Sep 4, 2022
1 parent c511b52 commit 549e181
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
26 changes: 24 additions & 2 deletions Servirtium.Core.Tests/Interactions/InteractionReplayerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,32 @@ public void GetServiceResponseForRequest_PathMismatchWithRecordedInteraction_Thr
}

[Fact]
public void Fooooo()
public void CheckThatBogusFileNameIsMadeAbsoluteToAidUserDebugging()
{
var replayer = new InteractionReplayer(null, null, null, null, null);
replayer.ReadPlaybackConversation(new StringReader("some script content"), "../../DoesNotExist.md");
try
{
replayer.ReadPlaybackConversation(new StringReader("some script content"), "../../DoesNotExist.md");
}
catch (ArgumentException e)
{
Assert.Matches("Markdown file that may be missing: .*Servirtium.Core.Tests/bin/DoesNotExist.md",
e.Message.Replace("\\","/"));
}
}

[Fact]
public void CheckThatBogusFileNameIsNotMentionedWhenItIsMissing()
{
var replayer = new InteractionReplayer(null, null, null, null, null);
try
{
replayer.ReadPlaybackConversation(new StringReader("some script content"),"no filename set");
}
catch (ArgumentException e)
{
Assert.StartsWith("No '## Interaction' found in conversation 'some script content '", e.Message);
}
}

[Fact]
Expand Down
8 changes: 6 additions & 2 deletions Servirtium.Core/Interactions/InteractionReplayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ public void ReadPlaybackConversation(TextReader conversationReader, string filen
}
catch (ArgumentException e)
{
throw new ArgumentException("Markdown file that may be missing: "
+ Path.GetFullPath(filename), e);
if (filename.Equals("no filename set"))
{
throw e;
}
var fullPath = Path.GetFullPath(filename);
throw new ArgumentException("Markdown file that may be missing: " + fullPath, e);
}
_logger.LogInformation($"Loaded {_allInteractions.Count()} interactions from '{filename}'");
}
Expand Down

0 comments on commit 549e181

Please sign in to comment.