public void CreateConnectionPool_should_throw_when_serverId_is_null()
        {
            var subject = new ExclusiveConnectionPoolFactory(_settings, _connectionFactory, _eventSubscriber);

            Action act = () => subject.CreateConnectionPool(null, _endPoint);
            act.ShouldThrow<ArgumentNullException>();
        }
        // methods
        public ICluster BuildCluster()
        {
            IStreamFactory streamFactory = new TcpStreamFactory(_tcpStreamSettings);
            // TODO: SSL gets handled here specifically...

            streamFactory = _streamFactoryWrapper(streamFactory);

            var connectionFactory = new BinaryConnectionFactory(
                _connectionSettings,
                streamFactory,
                _connectionListener);

            var connectionPoolFactory = new ExclusiveConnectionPoolFactory(
                _connectionPoolSettings,
                connectionFactory,
                _connectionPoolListener);

            var serverFactory = new ServerFactory(
                _serverSettings,
                connectionPoolFactory,
                connectionFactory,
                _serverListener);

            var clusterFactory = new ClusterFactory(
                _clusterSettings,
                serverFactory,
                _clusterListener);

            return clusterFactory.CreateCluster();
        }
        public void CreateConnectionPool_should_throw_when_endPoint_is_null()
        {
            var subject = new ExclusiveConnectionPoolFactory(_settings, _connectionFactory, _eventSubscriber);

            Action act = () => subject.CreateConnectionPool(_serverId, null);

            act.ShouldThrow <ArgumentNullException>();
        }
        public void CreateConnectionPool_should_return_a_ConnectionPool()
        {
            var subject = new ExclusiveConnectionPoolFactory(_settings, _connectionFactory, _eventSubscriber);

            var result = subject.CreateConnectionPool(_serverId, _endPoint);

            result.Should().NotBeNull();
            result.Should().BeOfType <ExclusiveConnectionPool>();
        }
        public void CreateConnectionPool_should_return_a_ConnectionPool()
        {
            var subject = new ExclusiveConnectionPoolFactory(_settings, _connectionFactory, null);

            var result = subject.CreateConnectionPool(_serverId, _endPoint);

            result.Should().NotBeNull();
            result.Should().BeOfType<ExclusiveConnectionPool>();
        }
        // methods
        private ICluster CreateCluster(ClusterKey clusterKey)
        {
            var clusterSettings = CreateClusterSettings(clusterKey);
            var serverSettings = CreateServerSettings(clusterKey);
            var connectionSettings = CreateConnectionSettings(clusterKey);
            var connectionPoolSettings = CreateConnectionPoolSettings(clusterKey);

            var listener = EmptyListener.Instance;
            var streamFactory = CreateStreamFactory(clusterKey);
            var connectionFactory = new BinaryConnectionFactory(connectionSettings, streamFactory, listener);
            var connectionPoolFactory = new ExclusiveConnectionPoolFactory(connectionPoolSettings, connectionFactory, listener);
            var serverFactory = new ServerFactory(serverSettings, connectionPoolFactory, connectionFactory, listener);
            var clusterFactory = new ClusterFactory(clusterSettings, serverFactory, listener);

            var cluster = clusterFactory.CreateCluster();
            cluster.Initialize();

            return cluster;
        }