-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84761c7
commit 8ec5042
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Sentry.PlatformAbstractions; | ||
|
||
namespace Sentry.Tests.Internals; | ||
|
||
public class AgggregateExceptionTests | ||
{ | ||
private static readonly string DefaultAggregateExceptionMessage = new AggregateException().Message; | ||
|
||
[Fact] | ||
public void AggregateException_GetRawMessage_Empty() | ||
{ | ||
var exception = new AggregateException(); | ||
|
||
var rawMessage = exception.GetRawMessage(); | ||
|
||
Assert.Equal(DefaultAggregateExceptionMessage, rawMessage); | ||
} | ||
|
||
[Fact] | ||
public void AggregateException_GetRawMessage_WithInnerExceptions() | ||
{ | ||
var exception = GetTestAggregateException(); | ||
|
||
var rawMessage = exception.GetRawMessage(); | ||
|
||
Assert.Equal(DefaultAggregateExceptionMessage, rawMessage); | ||
} | ||
|
||
[SkippableFact] | ||
public void AggregateException_GetRawMessage_DiffersFromMessage() | ||
{ | ||
// Sanity check: The message should be different than the raw message, except on full .NET Framework. | ||
// .NET, .NET Core, and Mono all override the Message property to append messages from the inner exceptions. | ||
// .NET Framework does not. | ||
|
||
Skip.If(RuntimeInfo.GetRuntime().IsNetFx()); | ||
|
||
var exception = GetTestAggregateException(); | ||
|
||
var rawMessage = exception.GetRawMessage(); | ||
|
||
Assert.NotEqual(exception.Message, rawMessage); | ||
} | ||
|
||
private static AggregateException GetTestAggregateException() => | ||
Assert.Throws<AggregateException>(() => | ||
{ | ||
var t1 = Task.Run(() => throw new Exception("Test 1")); | ||
var t2 = Task.Run(() => throw new Exception("Test 2")); | ||
Task.WaitAll(t1, t2); | ||
}); | ||
} |