Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Apr 13, 2023
1 parent 6b9d321 commit aaa707b
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
Mechanism: {
Type: generic,
Handled: true,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
Mechanism: {
Type: generic,
Handled: true,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
Mechanism: {
Type: generic,
Handled: true,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
Mechanism: {
Type: generic,
Handled: true,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
Mechanism: {
Type: generic,
Handled: true,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0,
Data: {
details: Do work always throws.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0,
Data: {
details: Do work always throws.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0,
Data: {
details: Do work always throws.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0,
Data: {
details: Do work always throws.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 0,
Data: {
details: Do work always throws.
}
Expand Down
6 changes: 5 additions & 1 deletion test/Sentry.Tests/ApiApprovalTests.Run.Core3_1.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ namespace Sentry
public bool IsEnvironmentUser { get; set; }
public bool IsGlobalModeEnabled { get; set; }
public bool JsonPreserveReferences { get; set; }
[System.Obsolete("This property is no longer used. It will be removed in a future version.")]
public bool KeepAggregateException { get; set; }
public long MaxAttachmentSize { get; set; }
public int MaxBreadcrumbs { get; set; }
Expand Down Expand Up @@ -1479,9 +1480,13 @@ namespace Sentry.Protocol
public Mechanism() { }
public System.Collections.Generic.IDictionary<string, object> Data { get; }
public string? Description { get; set; }
public int? ExceptionId { get; set; }
public bool? Handled { get; set; }
public string? HelpLink { get; set; }
public bool IsExceptionGroup { get; set; }
public System.Collections.Generic.IDictionary<string, object> Meta { get; }
public int? ParentId { get; set; }
public string? Source { get; set; }
public bool Synthetic { get; set; }
public string Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down Expand Up @@ -1597,6 +1602,5 @@ public static class SentryExceptionExtensions
{
public static void AddSentryContext(this System.Exception ex, string name, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { }
public static void AddSentryTag(this System.Exception ex, string name, string value) { }
public static System.Collections.Generic.IEnumerable<System.Exception> EnumerateChainedExceptions(this System.Exception exception, Sentry.SentryOptions options) { }
public static void SetSentryMechanism(this System.Exception ex, string type, string? description = null, bool? handled = default) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ namespace Sentry
public bool IsEnvironmentUser { get; set; }
public bool IsGlobalModeEnabled { get; set; }
public bool JsonPreserveReferences { get; set; }
[System.Obsolete("This property is no longer used. It will be removed in a future version.")]
public bool KeepAggregateException { get; set; }
public long MaxAttachmentSize { get; set; }
public int MaxBreadcrumbs { get; set; }
Expand Down Expand Up @@ -1479,9 +1480,13 @@ namespace Sentry.Protocol
public Mechanism() { }
public System.Collections.Generic.IDictionary<string, object> Data { get; }
public string? Description { get; set; }
public int? ExceptionId { get; set; }
public bool? Handled { get; set; }
public string? HelpLink { get; set; }
public bool IsExceptionGroup { get; set; }
public System.Collections.Generic.IDictionary<string, object> Meta { get; }
public int? ParentId { get; set; }
public string? Source { get; set; }
public bool Synthetic { get; set; }
public string Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down Expand Up @@ -1597,6 +1602,5 @@ public static class SentryExceptionExtensions
{
public static void AddSentryContext(this System.Exception ex, string name, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { }
public static void AddSentryTag(this System.Exception ex, string name, string value) { }
public static System.Collections.Generic.IEnumerable<System.Exception> EnumerateChainedExceptions(this System.Exception exception, Sentry.SentryOptions options) { }
public static void SetSentryMechanism(this System.Exception ex, string type, string? description = null, bool? handled = default) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ namespace Sentry
public bool IsEnvironmentUser { get; set; }
public bool IsGlobalModeEnabled { get; set; }
public bool JsonPreserveReferences { get; set; }
[System.Obsolete("This property is no longer used. It will be removed in a future version.")]
public bool KeepAggregateException { get; set; }
public long MaxAttachmentSize { get; set; }
public int MaxBreadcrumbs { get; set; }
Expand Down Expand Up @@ -1479,9 +1480,13 @@ namespace Sentry.Protocol
public Mechanism() { }
public System.Collections.Generic.IDictionary<string, object> Data { get; }
public string? Description { get; set; }
public int? ExceptionId { get; set; }
public bool? Handled { get; set; }
public string? HelpLink { get; set; }
public bool IsExceptionGroup { get; set; }
public System.Collections.Generic.IDictionary<string, object> Meta { get; }
public int? ParentId { get; set; }
public string? Source { get; set; }
public bool Synthetic { get; set; }
public string Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down Expand Up @@ -1597,6 +1602,5 @@ public static class SentryExceptionExtensions
{
public static void AddSentryContext(this System.Exception ex, string name, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { }
public static void AddSentryTag(this System.Exception ex, string name, string value) { }
public static System.Collections.Generic.IEnumerable<System.Exception> EnumerateChainedExceptions(this System.Exception exception, Sentry.SentryOptions options) { }
public static void SetSentryMechanism(this System.Exception ex, string type, string? description = null, bool? handled = default) { }
}
6 changes: 5 additions & 1 deletion test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ namespace Sentry
public bool IsEnvironmentUser { get; set; }
public bool IsGlobalModeEnabled { get; set; }
public bool JsonPreserveReferences { get; set; }
[System.Obsolete("This property is no longer used. It will be removed in a future version.")]
public bool KeepAggregateException { get; set; }
public long MaxAttachmentSize { get; set; }
public int MaxBreadcrumbs { get; set; }
Expand Down Expand Up @@ -1479,9 +1480,13 @@ namespace Sentry.Protocol
public Mechanism() { }
public System.Collections.Generic.IDictionary<string, object> Data { get; }
public string? Description { get; set; }
public int? ExceptionId { get; set; }
public bool? Handled { get; set; }
public string? HelpLink { get; set; }
public bool IsExceptionGroup { get; set; }
public System.Collections.Generic.IDictionary<string, object> Meta { get; }
public int? ParentId { get; set; }
public string? Source { get; set; }
public bool Synthetic { get; set; }
public string Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down Expand Up @@ -1597,6 +1602,5 @@ public static class SentryExceptionExtensions
{
public static void AddSentryContext(this System.Exception ex, string name, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { }
public static void AddSentryTag(this System.Exception ex, string name, string value) { }
public static System.Collections.Generic.IEnumerable<System.Exception> EnumerateChainedExceptions(this System.Exception exception, Sentry.SentryOptions options) { }
public static void SetSentryMechanism(this System.Exception ex, string type, string? description = null, bool? handled = default) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Mechanism: {
Type: generic,
Handled: false,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Mechanism: {
Type: generic,
Handled: false,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Mechanism: {
Type: generic,
Handled: false,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Mechanism: {
Type: generic,
Handled: false,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Mechanism: {
Type: generic,
Handled: false,
Synthetic: false
Synthetic: false,
IsExceptionGroup: false
}
}
],
Expand Down
52 changes: 52 additions & 0 deletions test/Sentry.Tests/Internals/AgggregateExceptionTests.cs
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);
});
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
[
{
Type: System.Exception,
Value: Inner message1
Value: Inner message2,
Mechanism: {
Type: chained,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 2,
ParentId: 0,
Source: InnerExceptions[1]
}
},
{
Type: System.Exception,
Value: Inner message2,
Value: Inner message1,
Mechanism: {
Type: chained,
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 1,
ParentId: 0,
Source: InnerExceptions[0]
}
},
{
Type: System.AggregateException,
Value: One or more errors occurred.,
Mechanism: {
Type: AppDomain.UnhandledException,
Handled: false,
Synthetic: false,
IsExceptionGroup: true,
ExceptionId: 0,
Data: {
foo: bar
}
Expand Down

This file was deleted.

Loading

0 comments on commit aaa707b

Please sign in to comment.