Skip to content

Commit

Permalink
Rename ConnectionFactory to ConnectionFactoryFactory.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed Jul 6, 2010
1 parent cf2bb52 commit 0e4a824
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
Expand Up @@ -37,7 +37,7 @@ private QueryMessage GenerateQueryMessage()
[Test]
public void TestReconnectOnce()
{
var conn = ConnectionFactory.GetConnection(string.Empty);
var conn = ConnectionFactoryFactory.GetConnection(string.Empty);
conn.Open();

WriteBadMessage(conn);
Expand All @@ -60,7 +60,7 @@ public void TestReconnectOnce()
public void TestSendQueryMessage()
{
//Connection conn = new Connection("10.141.153.2");
var conn = ConnectionFactory.GetConnection(string.Empty);
var conn = ConnectionFactoryFactory.GetConnection(string.Empty);
conn.Open();

var qmsg = GenerateQueryMessage();
Expand Down
Expand Up @@ -9,32 +9,32 @@ public class TestConnectionFactory
{
[TearDown]
public void TearDown (){
ConnectionFactory.Shutdown ();
ConnectionFactoryFactory.Shutdown ();
}

[Test]
public void TestGetConnection (){
var connection1 = ConnectionFactory.GetConnection (string.Empty);
var connection2 = ConnectionFactory.GetConnection (string.Empty);
var connection1 = ConnectionFactoryFactory.GetConnection (string.Empty);
var connection2 = ConnectionFactoryFactory.GetConnection (string.Empty);
Assert.IsNotNull (connection1);
Assert.IsNotNull (connection2);
Assert.AreEqual (1, ConnectionFactory.PoolCount);
Assert.AreEqual (1, ConnectionFactoryFactory.PoolCount);
}

[Test]
public void TestCreatePoolForEachUniqeConnectionString (){
ConnectionFactory.GetConnection (string.Empty);
ConnectionFactory.GetConnection (string.Empty);
ConnectionFactory.GetConnection ("Username=test");
ConnectionFactory.GetConnection ("Username=test");
ConnectionFactory.GetConnection ("Server=localhost");
Assert.AreEqual (3, ConnectionFactory.PoolCount);
ConnectionFactoryFactory.GetConnection (string.Empty);
ConnectionFactoryFactory.GetConnection (string.Empty);
ConnectionFactoryFactory.GetConnection ("Username=test");
ConnectionFactoryFactory.GetConnection ("Username=test");
ConnectionFactoryFactory.GetConnection ("Server=localhost");
Assert.AreEqual (3, ConnectionFactoryFactory.PoolCount);
}

[Test]
public void TestExceptionWhenMinimumPoolSizeIsGreaterThenMaximumPoolSize (){
try{
ConnectionFactory.GetConnection("MinimumPoolSize=50; MaximumPoolSize=10");
ConnectionFactoryFactory.GetConnection("MinimumPoolSize=50; MaximumPoolSize=10");
}catch(ArgumentException){
}catch(Exception){
Assert.Fail("Wrong exception thrown");
Expand Down
Expand Up @@ -11,7 +11,7 @@ public class TestPooledConnectionFactory
[TestFixtureSetUp]
public void SetUp()
{
ConnectionFactory.Shutdown();
ConnectionFactoryFactory.Shutdown();
}

[Test]
Expand Down
Expand Up @@ -126,7 +126,7 @@ private static void TryInsertData(Mongo mongo)
}

// clean connections
ConnectionFactory.Shutdown();
ConnectionFactoryFactory.Shutdown();
}
}
}
Expand Up @@ -10,7 +10,7 @@ public class TestPooledConnectionFactory
[TestFixtureSetUp]
public void SetUp()
{
ConnectionFactory.Shutdown();
ConnectionFactoryFactory.Shutdown();
}

[Test]
Expand Down
Expand Up @@ -7,17 +7,17 @@ namespace MongoDB.Connections
/// <summary>
///
/// </summary>
internal static class ConnectionFactory
internal static class ConnectionFactoryFactory
{
private static readonly TimeSpan MaintenaceWakeup = TimeSpan.FromSeconds(10);
private static readonly Timer MaintenanceTimer = new Timer(o => OnMaintenaceWakeup());
private static readonly Dictionary<string, IConnectionFactory> Factorys = new Dictionary<string, IConnectionFactory>();
private static readonly object SyncObject = new object();

/// <summary>
/// Initializes the <see cref="ConnectionFactory"/> class.
/// Initializes the <see cref="ConnectionFactoryFactory"/> class.
/// </summary>
static ConnectionFactory()
static ConnectionFactoryFactory()
{
MaintenanceTimer.Change(MaintenaceWakeup, MaintenaceWakeup);
}
Expand Down
2 changes: 1 addition & 1 deletion source/MongoDB/Mongo.cs
Expand Up @@ -42,7 +42,7 @@ public Mongo(string connectionString)
configuration.ValidateAndSeal();

_configuration = configuration;
_connection = ConnectionFactory.GetConnection(configuration.ConnectionString);
_connection = ConnectionFactoryFactory.GetConnection(configuration.ConnectionString);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion source/MongoDB/MongoDB.csproj
Expand Up @@ -273,7 +273,7 @@
<Compile Include="Connections\RawConnection.cs" />
<Compile Include="CollectionMetadata.cs" />
<Compile Include="Connections\Connection.cs" />
<Compile Include="Connections\ConnectionFactory.cs" />
<Compile Include="Connections\ConnectionFactoryFactory.cs" />
<Compile Include="Connections\ConnectionFactoryBase.cs" />
<Compile Include="Connections\IConnectionFactory.cs" />
<Compile Include="Connections\PooledConnectionFactory.cs" />
Expand Down
2 changes: 1 addition & 1 deletion source/MongoDB/MongoDatabase.cs
Expand Up @@ -31,7 +31,7 @@ public MongoDatabase(string connectionString)
/// <param name="configuration">The configuration.</param>
public MongoDatabase(MongoConfiguration configuration)
: this(configuration,
ConnectionFactory.GetConnection(configuration.ConnectionString),
ConnectionFactoryFactory.GetConnection(configuration.ConnectionString),
new MongoConnectionStringBuilder(configuration.ConnectionString).Database)
{
//Todo: Add check for null
Expand Down

0 comments on commit 0e4a824

Please sign in to comment.