forked from samus/mongodb-csharp
/
TestConnectionFactory.cs
44 lines (40 loc) · 1.58 KB
/
TestConnectionFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using MongoDB.Connections;
using NUnit.Framework;
namespace MongoDB.IntegrationTests.Connections
{
[TestFixture]
public class TestConnectionFactory
{
[TearDown]
public void TearDown (){
ConnectionFactoryFactory.Shutdown ();
}
[Test]
public void TestGetConnection (){
var connection1 = ConnectionFactoryFactory.GetConnection (string.Empty);
var connection2 = ConnectionFactoryFactory.GetConnection (string.Empty);
Assert.IsNotNull (connection1);
Assert.IsNotNull (connection2);
Assert.AreEqual (1, ConnectionFactoryFactory.PoolCount);
}
[Test]
public void TestCreatePoolForEachUniqeConnectionString (){
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{
ConnectionFactoryFactory.GetConnection("MinimumPoolSize=50; MaximumPoolSize=10");
}catch(ArgumentException){
}catch(Exception){
Assert.Fail("Wrong exception thrown");
}
}
}
}