diff --git a/tests/MongoDB.Driver.TestHelpers/DatabaseFixture.cs b/tests/MongoDB.Driver.TestHelpers/DatabaseFixture.cs index 63baa10308..e18ae14c8c 100644 --- a/tests/MongoDB.Driver.TestHelpers/DatabaseFixture.cs +++ b/tests/MongoDB.Driver.TestHelpers/DatabaseFixture.cs @@ -49,7 +49,7 @@ public virtual IMongoCollection GetCollection(Action if (string.IsNullOrEmpty(collectionName)) { var stack = new System.Diagnostics.StackTrace(); - var frame = stack.GetFrame(1); // skip 1 frame to get the calling method info + var frame = stack.GetFrame(2); // skip 2 frame to get the calling method info (this method and IntegrationTest method) var method = frame.GetMethod(); collectionName = $"{method.DeclaringType.Name}.{method.Name}"; } diff --git a/tests/MongoDB.Driver.TestHelpers/IntegrationTest.cs b/tests/MongoDB.Driver.TestHelpers/IntegrationTest.cs index e8a777438f..1c0d683df4 100644 --- a/tests/MongoDB.Driver.TestHelpers/IntegrationTest.cs +++ b/tests/MongoDB.Driver.TestHelpers/IntegrationTest.cs @@ -25,17 +25,17 @@ namespace MongoDB.Driver.Tests public abstract class IntegrationTest : LoggableTestClass, IClassFixture where TFixture : DatabaseFixture { + private readonly TFixture _fixture; + protected IntegrationTest(ITestOutputHelper testOutputHelper, TFixture fixture) : base(testOutputHelper) { - Fixture = fixture; + _fixture = fixture; } - protected TFixture Fixture { get; } - public IMongoClient GetMongoClient(Action configure = null) { - return Fixture.GetMongoClient(settings => + return _fixture.GetMongoClient(settings => { settings.LoggingSettings = LoggingSettings; configure?.Invoke(settings); @@ -44,7 +44,7 @@ public IMongoClient GetMongoClient(Action configure = null) public IMongoDatabase GetDatabase(Action configure = null) { - return Fixture.GetDatabase(settings => + return _fixture.GetDatabase(settings => { settings.LoggingSettings = LoggingSettings; configure?.Invoke(settings); @@ -53,7 +53,7 @@ public IMongoDatabase GetDatabase(Action configure = null) public IMongoCollection GetCollection(Action configure = null, string collectionName = null) { - return Fixture.GetCollection(settings => + return _fixture.GetCollection(settings => { settings.LoggingSettings = LoggingSettings; configure?.Invoke(settings); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp4066Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp4066Tests.cs index 7b908009b5..c787aa190c 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp4066Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp4066Tests.cs @@ -31,7 +31,7 @@ public CSharp4066Tests(ITestOutputHelper testOutputHelper, DatabaseFixture fixtu [Fact] public void String_comparison_in_filter_should_use_custom_serializer() { - var collection = Fixture.GetCollection(); + var collection = GetCollection(); var id = "0102030405060708090a0b0c"; collection.InsertMany(