Skip to content

Commit

Permalink
Fix collection name resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Poliakov committed Oct 17, 2024
1 parent c2c4ad2 commit f4578b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/MongoDB.Driver.TestHelpers/DatabaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public virtual IMongoCollection<T> GetCollection<T>(Action<MongoClientSettings>
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}";
}
Expand Down
12 changes: 6 additions & 6 deletions tests/MongoDB.Driver.TestHelpers/IntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ namespace MongoDB.Driver.Tests
public abstract class IntegrationTest<TFixture> : LoggableTestClass, IClassFixture<TFixture>
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<MongoClientSettings> configure = null)
{
return Fixture.GetMongoClient(settings =>
return _fixture.GetMongoClient(settings =>
{
settings.LoggingSettings = LoggingSettings;
configure?.Invoke(settings);
Expand All @@ -44,7 +44,7 @@ public IMongoClient GetMongoClient(Action<MongoClientSettings> configure = null)

public IMongoDatabase GetDatabase(Action<MongoClientSettings> configure = null)
{
return Fixture.GetDatabase(settings =>
return _fixture.GetDatabase(settings =>
{
settings.LoggingSettings = LoggingSettings;
configure?.Invoke(settings);
Expand All @@ -53,7 +53,7 @@ public IMongoDatabase GetDatabase(Action<MongoClientSettings> configure = null)

public IMongoCollection<T> GetCollection<T>(Action<MongoClientSettings> configure = null, string collectionName = null)
{
return Fixture.GetCollection<T>(settings =>
return _fixture.GetCollection<T>(settings =>
{
settings.LoggingSettings = LoggingSettings;
configure?.Invoke(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<C>();
var collection = GetCollection<C>();

var id = "0102030405060708090a0b0c";
collection.InsertMany(
Expand Down

0 comments on commit f4578b4

Please sign in to comment.