public void should_dispose_connections_on_pool_disposal() { var conString = string.Empty; var connection = new Mock <IConnection>(); var provider = new Mock <IConnectionProvider <IConnection> >(); provider.Setup(cp => cp.Create(conString)).Returns(() => connection.Object); var pool = new FakeConnectionPool(provider.Object); pool.Get(conString, false, CancellationToken.None); pool.Dispose(); connection.Verify(c => c.Dispose()); }
public void should_throw_if_disposed_pool_is_accessed() { var conString = string.Empty; var connection = new Mock <IConnection>(); var provider = new Mock <IConnectionProvider <IConnection> >(); provider.Setup(cp => cp.Create(conString)).Returns(() => connection.Object); var pool = new FakeConnectionPool(provider.Object); pool.Dispose(); try { pool.Get(conString, false, CancellationToken.None); Assert.Fail("Should throw if a disposed pool is accessed"); } catch (Exception) { } }