Skip to content

Commit 31e9125

Browse files
committed
test(transaction): expect "data" via TransactionTracer
1 parent f57868e commit 31e9125

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

test/Sentry.Tests/Protocol/SentryTransactionTests.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
231231

232232
// Act
233233
var finalTransaction = new SentryTransaction(transaction);
234-
var actualString = finalTransaction.ToJsonString(_testOutputLogger);
234+
var actualString = finalTransaction.ToJsonString(_testOutputLogger, indented: true);
235235
var actual = Json.Parse(actualString, SentryTransaction.FromJson);
236236

237237
// Assert
@@ -245,14 +245,29 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
245245
return o;
246246
});
247247

248-
using (_ = new AssertionScope())
249-
{
250-
KeyValuePair<string, string> expectedData = new("extra_key", "extra_value");
251-
finalTransaction.Data.Should().ContainSingle().Which.Should().Be(expectedData);
252-
finalTransaction.Contexts.Trace.Data.Should().ContainSingle().Which.Should().Be(expectedData);
253-
actual.Data.Should().ContainSingle().Which.Should().Be(expectedData);
254-
actual.Contexts.Trace.Data.Should().ContainSingle().Which.Should().Be(expectedData);
255-
}
248+
Assert.Contains($$"""
249+
"contexts": {
250+
".NET Framework": {
251+
".NET Framework": "\u0022v2.0.50727\u0022, \u0022v3.0\u0022, \u0022v3.5\u0022",
252+
".NET Framework Client": "\u0022v4.8\u0022, \u0022v4.0.0.0\u0022",
253+
".NET Framework Full": "\u0022v4.8\u0022"
254+
},
255+
"context_key": "context_value",
256+
"trace": {
257+
"type": "trace",
258+
"span_id": "{{context.SpanId}}",
259+
"parent_span_id": "{{context.ParentSpanId}}",
260+
"trace_id": "{{context.TraceId}}",
261+
"op": "op123",
262+
"origin": "auto.serialize.transaction",
263+
"description": "desc123",
264+
"status": "aborted",
265+
"data": {
266+
"extra_key": "extra_value"
267+
}
268+
}
269+
}
270+
""", actualString);
256271
}
257272

258273
[Fact]

0 commit comments

Comments
 (0)