diff --git a/src/EphemeralMongo.Core/MongoRunner.cs b/src/EphemeralMongo.Core/MongoRunner.cs index f763d1c..2aecbeb 100644 --- a/src/EphemeralMongo.Core/MongoRunner.cs +++ b/src/EphemeralMongo.Core/MongoRunner.cs @@ -27,7 +27,8 @@ private MongoRunner(IFileSystem fileSystem, IPortFactory portFactory, IMongoExec public static IMongoRunner Run(MongoRunnerOptions? options = null) { - var runner = new MongoRunner(new FileSystem(), new PortFactory(), new MongoExecutableLocator(), new MongoProcessFactory(), options ?? new MongoRunnerOptions()); + var optionsCopy = options == null ? new MongoRunnerOptions() : new MongoRunnerOptions(options); + var runner = new MongoRunner(new FileSystem(), new PortFactory(), new MongoExecutableLocator(), new MongoProcessFactory(), optionsCopy); return runner.RunInternal(); } diff --git a/src/EphemeralMongo.Core/MongoRunnerOptions.cs b/src/EphemeralMongo.Core/MongoRunnerOptions.cs index 73f636e..cc26bae 100644 --- a/src/EphemeralMongo.Core/MongoRunnerOptions.cs +++ b/src/EphemeralMongo.Core/MongoRunnerOptions.cs @@ -7,6 +7,30 @@ public sealed class MongoRunnerOptions private TimeSpan _connectionTimeout = TimeSpan.FromSeconds(30); private TimeSpan _replicaSetSetupTimeout = TimeSpan.FromSeconds(10); + public MongoRunnerOptions() + { + } + + public MongoRunnerOptions(MongoRunnerOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + this._dataDirectory = options._dataDirectory; + this._binaryDirectory = options._binaryDirectory; + this._connectionTimeout = options._connectionTimeout; + this._replicaSetSetupTimeout = options._replicaSetSetupTimeout; + + this.AdditionalArguments = options.AdditionalArguments; + this.UseSingleNodeReplicaSet = options.UseSingleNodeReplicaSet; + this.StandardOuputLogger = options.StandardOuputLogger; + this.StandardErrorLogger = options.StandardErrorLogger; + this.ReplicaSetName = options.ReplicaSetName; + this.MongoPort = options.MongoPort; + } + public string? DataDirectory { get => this._dataDirectory; diff --git a/src/EphemeralMongo.Core/PublicAPI.Shipped.txt b/src/EphemeralMongo.Core/PublicAPI.Shipped.txt index 4e2c10e..02b10cb 100644 --- a/src/EphemeralMongo.Core/PublicAPI.Shipped.txt +++ b/src/EphemeralMongo.Core/PublicAPI.Shipped.txt @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable EphemeralMongo.IMongoRunner EphemeralMongo.IMongoRunner.ConnectionString.get -> string! EphemeralMongo.IMongoRunner.Export(string! database, string! collection, string! outputFilePath, string? additionalArguments = null) -> void @@ -15,6 +15,7 @@ EphemeralMongo.MongoRunnerOptions.ConnectionTimeout.set -> void EphemeralMongo.MongoRunnerOptions.DataDirectory.get -> string? EphemeralMongo.MongoRunnerOptions.DataDirectory.set -> void EphemeralMongo.MongoRunnerOptions.MongoRunnerOptions() -> void +EphemeralMongo.MongoRunnerOptions.MongoRunnerOptions(EphemeralMongo.MongoRunnerOptions! options) -> void EphemeralMongo.MongoRunnerOptions.ReplicaSetSetupTimeout.get -> System.TimeSpan EphemeralMongo.MongoRunnerOptions.ReplicaSetSetupTimeout.set -> void EphemeralMongo.MongoRunnerOptions.StandardErrorLogger.get -> EphemeralMongo.Logger?