Permalink
Browse files

Use MongoConfiguration.Default instead of creating new ones on Mongo …

…ctor.
  • Loading branch information...
1 parent d4f4d20 commit 969069f9cdb466685eabf16acb110d2137e4a84c @lanwin lanwin committed Nov 1, 2010
View
2 source/MongoDB.Tests/IntegrationTests/TestMongo.cs
@@ -14,7 +14,7 @@ public class TestMongo
using(var m = new Mongo())
{
//Connection string not needed since connect not called and it would screw up the test.
- Assert.AreEqual(string.Empty, m.ConnectionString);
+ Assert.AreEqual(_connectionString, m.ConnectionString);
}
}
View
18 source/MongoDB/Configuration/MongoConfiguration.cs
@@ -48,6 +48,24 @@ public static MongoConfiguration Default
}
}
+ /// <summary>
+ /// Clones the specified configuration with a new
+ /// connection string.
+ /// </summary>
+ /// <param name="connectionString">The connection string.</param>
+ /// <returns></returns>
+ public MongoConfiguration Clone(string connectionString)
+ {
+ return new MongoConfiguration
+ {
+ ConnectionString = connectionString,
+ MappingStore = _mappingStore,
+ ReadLocalTime = _readLocalTime,
+ SerializationFactory = _serializationFactory,
+ IsModifiable = false
+ };
+ }
+
///<summary>
///</summary>
public bool IsModifiable { get; private set; }
View
6 source/MongoDB/Mongo.cs
@@ -9,7 +9,7 @@ namespace MongoDB
/// <summary>
/// Description of Mongo.
/// </summary>
- public class Mongo : IDisposable, IMongo
+ public class Mongo : IMongo
{
private readonly MongoConfiguration _configuration;
private readonly Connection _connection;
@@ -18,7 +18,7 @@ public class Mongo : IDisposable, IMongo
/// Initializes a new instance of the <see cref = "Mongo" /> class.
/// </summary>
public Mongo()
- : this(new MongoConfiguration())
+ : this(MongoConfiguration.Default)
{
}
@@ -27,7 +27,7 @@ public Mongo()
/// </summary>
/// <param name = "connectionString">The connection string.</param>
public Mongo(string connectionString)
- : this(new MongoConfiguration {ConnectionString = connectionString})
+ : this(MongoConfiguration.Default.Clone(connectionString))
{
}

0 comments on commit 969069f

Please sign in to comment.