-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityFrameworkCoreTests.cs
54 lines (43 loc) · 1.6 KB
/
EntityFrameworkCoreTests.cs
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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#if NET
using IntegrationTests.Helpers;
using Xunit.Abstractions;
namespace IntegrationTests;
public class EntityFrameworkCoreTests : TestHelper
{
public EntityFrameworkCoreTests(ITestOutputHelper output)
: base("EntityFrameworkCore", output)
{
}
public static TheoryData<string, bool> GetData()
{
var theoryData = new TheoryData<string, bool>();
foreach (var version in LibraryVersion.EntityFrameworkCore)
{
theoryData.Add(version, true);
theoryData.Add(version, false);
}
return theoryData;
}
[Theory]
[Trait("Category", "EndToEnd")]
[MemberData(nameof(GetData))]
public void SubmitTraces(string packageVersion, bool dbStatementForText)
{
SetEnvironmentVariable("OTEL_DOTNET_AUTO_ENTITYFRAMEWORKCORE_SET_DBSTATEMENT_FOR_TEXT", dbStatementForText.ToString());
using var collector = new MockSpansCollector(Output);
SetExporter(collector);
if (dbStatementForText)
{
collector.Expect("OpenTelemetry.Instrumentation.EntityFrameworkCore", span => span.Attributes.Any(attr => attr.Key == "db.statement" && !string.IsNullOrWhiteSpace(attr.Value?.StringValue)));
}
else
{
collector.Expect("OpenTelemetry.Instrumentation.EntityFrameworkCore", span => span.Attributes.All(attr => attr.Key != "db.statement"));
}
RunTestApplication(new TestSettings { PackageVersion = packageVersion });
collector.AssertExpectations();
}
}
#endif