Skip to content

Commit

Permalink
Add a tests and filter out nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean committed May 21, 2024
1 parent e471e0d commit 159a5ee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static IEnumerable<PEDebugInformation> GetDebugInfoForStackFrames(IEnume
return Enumerable.Empty<PEDebugInformation>();
}

var imageMap = DebugInformationCache.Values.ToDictionary(k => k.Signature);
var imageMap = DebugInformationCache.Values.Where(x => x != null).ToDictionary(k => k.Signature);
var imageSet = new HashSet<PEDebugInformation>();

foreach (var stackFrame in frames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private static IEnumerable<PEDebugInformation> GetDebugInfoForStackFrames(IEnume
return Enumerable.Empty<PEDebugInformation>();
}

var imageMap = DebugInformationCache.Values.ToDictionary(k => k.Signature);
var imageMap = DebugInformationCache.Values.Where(x => x != null).ToDictionary(k => k.Signature);
var imageSet = new HashSet<PEDebugInformation>();

foreach (var stackFrame in frames)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Mindscape.Raygun4Net.NetCore.Tests
{
Expand Down Expand Up @@ -45,5 +46,14 @@ public void IncludeNamespaceInExceptionClassName()
var message = RaygunErrorMessageBuilder.Build(_exception);
Assert.That("System.InvalidOperationException", Is.EqualTo(message.ClassName));
}

[Test]
public void ErrorMessageBuilder_WhenAssembliesAreAvailable_HasImageInfo()
{
var errorMessage = RaygunErrorMessageBuilder.Build(_exception);
Assert.That(errorMessage.Images, Is.Not.Null);
Assert.That(errorMessage.Images, Is.Not.Empty);
Assert.That(errorMessage.StackTrace.All(x => x.ImageSignature != null), Is.True);
}
}
}
10 changes: 10 additions & 0 deletions Mindscape.Raygun4Net.Tests/RaygunErrorMessageExceptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mindscape.Raygun4Net.Builders;
using Mindscape.Raygun4Net.Tests.Model;
using NUnit.Framework;
Expand Down Expand Up @@ -48,5 +49,14 @@ public void IncludeNamespaceInExceptionClassName()
var message = RaygunErrorMessageBuilder.Build(_exception);
Assert.That("System.InvalidOperationException", Is.EqualTo(message.ClassName));
}

[Test]
public void ErrorMessageBuilder_WhenAssembliesAreAvailable_HasImageInfo()
{
var errorMessage = RaygunErrorMessageBuilder.Build(_exception);
Assert.That(errorMessage.Images, Is.Not.Null);
Assert.That(errorMessage.Images, Is.Not.Empty);
Assert.That(errorMessage.StackTrace.All(x => x.ImageSignature != null), Is.True);
}
}
}

0 comments on commit 159a5ee

Please sign in to comment.