-
-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathNativeScopeObserverTests.cs
More file actions
65 lines (53 loc) · 1.97 KB
/
Copy pathNativeScopeObserverTests.cs
File metadata and controls
65 lines (53 loc) · 1.97 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Globalization;
using NUnit.Framework;
namespace Sentry.Unity.iOS.Tests;
public class IosNativeScopeObserverTests
{
[Test]
public void GetTimestamp_ReturnStringConformsToISO8601()
{
var timestamp = DateTimeOffset.UtcNow;
var timestampString = NativeScopeObserver.GetTimestamp(timestamp);
var actualTimestamp = DateTimeOffset.ParseExact(timestampString, "o", CultureInfo.InvariantCulture);
Assert.AreEqual(timestamp, actualTimestamp);
}
[Test]
[TestCase(BreadcrumbLevel.Debug, 1)]
[TestCase(BreadcrumbLevel.Info, 2)]
[TestCase(BreadcrumbLevel.Warning, 3)]
[TestCase(BreadcrumbLevel.Error, 4)]
[TestCase(BreadcrumbLevel.Fatal, 5)]
public void GetBreadcrumbLevel_TestCases(BreadcrumbLevel level, int expectedNativeLevel)
{
var actualLevel = NativeScopeObserver.GetBreadcrumbLevel(level);
Assert.AreEqual(actualLevel, expectedNativeLevel);
}
[Test]
public void GetBreadcrumbData_WithData_BuildsParallelArrays()
{
var breadcrumb = new Breadcrumb("message", "type", new Dictionary<string, string>
{
{ "key1", "value1" },
{ "key2", "value2" },
});
var count = NativeScopeObserver.GetBreadcrumbData(breadcrumb, out var keys, out var values);
Assert.AreEqual(2, count);
Assert.IsNotNull(keys);
Assert.IsNotNull(values);
Assert.AreEqual("key1", keys![0]);
Assert.AreEqual("value1", values![0]);
Assert.AreEqual("key2", keys[1]);
Assert.AreEqual("value2", values[1]);
}
[Test]
public void GetBreadcrumbData_WithoutData_ReturnsZeroAndNullArrays()
{
var breadcrumb = new Breadcrumb("message", "type");
var count = NativeScopeObserver.GetBreadcrumbData(breadcrumb, out var keys, out var values);
Assert.AreEqual(0, count);
Assert.IsNull(keys);
Assert.IsNull(values);
}
}