Skip to content

Commit

Permalink
refactor: keep the fluent api in a single chain
Browse files Browse the repository at this point in the history
  • Loading branch information
the-avid-engineer committed Aug 30, 2023
1 parent a0c12be commit 7d6fe7c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Testcontainers.MongoDb/MongoDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,21 @@ public override MongoDbContainer Build()
/// <inheritdoc />
protected override MongoDbBuilder Init()
{
var builder = base.Init()
.WithImage(MongoDbImage)
.WithPortBinding(MongoDbPort, true)
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil()));
string username = null;
string password = null;

if (_useDefaultCredentials)
{
builder = builder
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword);
username = DefaultUsername;
password = DefaultPassword;
}

return builder;
return base.Init()
.WithImage(MongoDbImage)
.WithPortBinding(MongoDbPort, true)
.WithUsername(username)
.WithPassword(password)
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil()));
}

/// <inheritdoc />
Expand Down

0 comments on commit 7d6fe7c

Please sign in to comment.