-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathErrorInfoTests.cs
More file actions
39 lines (35 loc) · 1.17 KB
/
ErrorInfoTests.cs
File metadata and controls
39 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-Present Datadog, Inc.
using System;
using System.Runtime.CompilerServices;
using NUnit.Framework;
namespace Datadog.Unity.Tests
{
public class ErrorInfoTests
{
[Test]
public void ExceptionIsCoercedToRuntimeError()
{
ErrorInfo err = null;
try
{
FunctionThatThrows();
}
catch (Exception e)
{
err = e;
}
Assert.NotNull(err);
Assert.NotNull(err.Exception);
Assert.AreEqual("System.InvalidCastException", err.Type);
Assert.AreEqual("very bad cast", err.Message);
StringAssert.Contains("at Datadog.Unity.Tests.ErrorInfoTests.FunctionThatThrows () [0x", err.StackTrace);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void FunctionThatThrows()
{
throw new InvalidCastException("very bad cast");
}
}
}