public void CreateConnection_should_throw_an_ArgumentNullException_when_serverId_is_null()
        {
            var streamFactory = Substitute.For<IStreamFactory>();
            var eventSubscriber = Substitute.For<IEventSubscriber>();
            var subject = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            Action act = () => subject.CreateConnection(null, new DnsEndPoint("localhost", 27017));
            act.ShouldThrow<ArgumentNullException>();
        }
        public void CreateConnection_should_throw_an_ArgumentNullException_when_serverId_is_null()
        {
            var streamFactory   = new Mock <IStreamFactory>().Object;
            var eventSubscriber = new Mock <IEventSubscriber>().Object;
            var subject         = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            Action act = () => subject.CreateConnection(null, new DnsEndPoint("localhost", 27017));

            act.ShouldThrow <ArgumentNullException>();
        }
        public void CreateConnection_should_throw_an_ArgumentNullException_when_serverId_is_null()
        {
            var streamFactory = Substitute.For <IStreamFactory>();
            var listener      = Substitute.For <IConnectionListener>();
            var subject       = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                listener);

            Action act = () => subject.CreateConnection(null, new DnsEndPoint("localhost", 27017));

            act.ShouldThrow <ArgumentNullException>();
        }
        public void CreateConnection_should_return_a_BinaryConnection()
        {
            var streamFactory = Substitute.For<IStreamFactory>();
            var listener = Substitute.For<IConnectionListener>();
            var subject = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                listener);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            var connection = subject.CreateConnection(serverId, serverId.EndPoint);
            connection.Should().NotBeNull();
            connection.Should().BeOfType<BinaryConnection>();
        }
Esempio n. 5
0
        public void CreateConnection_should_throw_an_ArgumentNullException_when_endPoint_is_null()
        {
            var streamFactory   = Substitute.For <IStreamFactory>();
            var eventSubscriber = Substitute.For <IEventSubscriber>();
            var subject         = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            Action act = () => subject.CreateConnection(serverId, null);

            act.ShouldThrow <ArgumentNullException>();
        }
        public void CreateConnection_should_return_a_BinaryConnection()
        {
            var streamFactory   = new Mock <IStreamFactory>().Object;
            var eventSubscriber = new Mock <IEventSubscriber>().Object;
            var subject         = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            var connection = subject.CreateConnection(serverId, serverId.EndPoint);

            connection.Should().NotBeNull();
            connection.Should().BeOfType <BinaryConnection>();
        }
        public void CreateConnection_should_return_a_BinaryConnection()
        {
            var streamFactory = Substitute.For <IStreamFactory>();
            var listener      = Substitute.For <IConnectionListener>();
            var subject       = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                listener);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            var connection = subject.CreateConnection(serverId, serverId.EndPoint);

            connection.Should().NotBeNull();
            connection.Should().BeOfType <BinaryConnection>();
        }
        public void CreateConnection_should_throw_an_ArgumentNullException_when_endPoint_is_null()
        {
            var streamFactory = Substitute.For<IStreamFactory>();
            var listener = Substitute.For<IConnectionListener>();
            var subject = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                listener);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            Action act = () => subject.CreateConnection(serverId, null);
            act.ShouldThrow<ArgumentNullException>();
        }
        public void CreateConnection_should_return_a_BinaryConnection()
        {
            var streamFactory = new Mock<IStreamFactory>().Object;
            var eventSubscriber = new Mock<IEventSubscriber>().Object;
            var subject = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            var connection = subject.CreateConnection(serverId, serverId.EndPoint);
            connection.Should().NotBeNull();
            connection.Should().BeOfType<BinaryConnection>();
        }
        public void CreateConnection_should_throw_an_ArgumentNullException_when_endPoint_is_null()
        {
            var streamFactory = new Mock<IStreamFactory>().Object;
            var eventSubscriber = new Mock<IEventSubscriber>().Object;
            var subject = new BinaryConnectionFactory(
                new ConnectionSettings(),
                streamFactory,
                eventSubscriber);

            var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017));

            Action act = () => subject.CreateConnection(serverId, null);
            act.ShouldThrow<ArgumentNullException>();
        }