Пример #1
0
        public void Dispose_should_call_dispose_on_connection_source()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            subject.Dispose();

            _connectionSource.Received().Dispose();
        }
Пример #2
0
        public void GetWriteConnectionSourceAsync_should_fork_the_connectionSource()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            subject.GetWriteConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);

            _connectionSource.Received().Fork();
        }
        public void GetReadConnectionSourceAsync_should_fork_the_connectionSource()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            subject.GetReadConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);

            _connectionSource.Received().Fork();
        }
        public void GetWriteConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);
            subject.Dispose();

            Action act = () => subject.GetWriteConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);

            act.ShouldThrow<ObjectDisposedException>();
        }
Пример #5
0
        public void GetWriteConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            subject.Dispose();

            Action act = () => subject.GetWriteConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);

            act.ShouldThrow <ObjectDisposedException>();
        }
Пример #6
0
        public void Constructor_should_not_fork_connectionSource()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            _connectionSource.DidNotReceive().Fork();
        }
        public void Constructor_should_not_fork_connectionSource()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            _connectionSource.DidNotReceive().Fork();
        }
        public void Dispose_should_call_dispose_on_connection_source()
        {
            var subject = new ConnectionSourceReadWriteBinding(_connectionSource, ReadPreference.Primary);

            subject.Dispose();

            _connectionSource.Received().Dispose();
        }
        /// <summary>
        /// Checks whether the server is alive (throws an exception if not).
        /// </summary>
        public void Ping()
        {
            var messageEncoderSettings = GetMessageEncoderSettings();
            var operation = new PingOperation(messageEncoderSettings);

            var server = GetServer();
            using (var connectionSource = new ConnectionSourceHandle(new ServerConnectionSource(server)))
            using (var connectionSourceBinding = new ConnectionSourceReadWriteBinding(connectionSource, ReadPreference.PrimaryPreferred))
            {
                operation.Execute(connectionSourceBinding, _settings.ConnectTimeout, CancellationToken.None);
            }
        }