public void GetReadConnectionSourceAsync_should_get_the_connection_source_from_the_read_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

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

            _readBinding.Received().GetReadConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);
        }
Ejemplo n.º 2
0
        public void GetWriteChannelSourceAsync_should_get_the_connection_source_from_the_write_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.GetWriteChannelSourceAsync(CancellationToken.None);

            _writeBinding.Received().GetWriteChannelSourceAsync(CancellationToken.None);
        }
        public void GetReadConnectionSourceAsync_should_get_the_connection_source_from_the_read_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

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

            _readBinding.Received().GetReadConnectionSourceAsync(Timeout.InfiniteTimeSpan, CancellationToken.None);
        }
        public void GetReadChannelSourceAsync_should_throw_if_disposed()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);
            subject.Dispose();

            Action act = () => subject.GetReadChannelSourceAsync(CancellationToken.None);

            act.ShouldThrow<ObjectDisposedException>();
        }
Ejemplo n.º 5
0
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new SplitReadWriteBinding(_mockReadBinding.Object, _mockWriteBinding.Object);

            subject.Dispose();

            _mockReadBinding.Verify(b => b.Dispose(), Times.Once);
            _mockWriteBinding.Verify(b => b.Dispose(), Times.Once);
        }
        public void GetWriteConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);
            subject.Dispose();

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

            act.ShouldThrow<ObjectDisposedException>();
        }
Ejemplo n.º 7
0
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.Dispose();

            _readBinding.Received().Dispose();
            _writeBinding.Received().Dispose();
        }
Ejemplo n.º 8
0
        public void GetWriteChannelSourceAsync_should_throw_if_disposed()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.Dispose();

            Action act = () => subject.GetWriteChannelSourceAsync(CancellationToken.None);

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void GetReadConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.Dispose();

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

            act.ShouldThrow <ObjectDisposedException>();
        }
Ejemplo n.º 10
0
        public void constructor_with_read_and_write_bindings_should_initialize_instance()
        {
            var session          = new Mock <ICoreSessionHandle>().Object;
            var mockReadBinding  = new Mock <IReadBinding>();
            var mockWriteBinding = new Mock <IWriteBinding>();

            mockReadBinding.SetupGet(m => m.Session).Returns(session);
            mockWriteBinding.SetupGet(m => m.Session).Returns(session);

            var result = new SplitReadWriteBinding(mockReadBinding.Object, mockWriteBinding.Object);

            result._readBinding().Should().BeSameAs(mockReadBinding.Object);
            result._writeBinding().Should().BeSameAs(mockWriteBinding.Object);
        }
Ejemplo n.º 11
0
        public void Session_should_delegate_to_read_binding()
        {
            var session          = new Mock <ICoreSessionHandle>().Object;
            var mockReadBinding  = new Mock <IReadBinding>();
            var mockWriteBinding = new Mock <IWriteBinding>();

            mockReadBinding.SetupGet(m => m.Session).Returns(session);
            mockWriteBinding.SetupGet(m => m.Session).Returns(session);
            var subject = new SplitReadWriteBinding(mockReadBinding.Object, mockWriteBinding.Object);

            var result = subject.Session;

            mockReadBinding.Verify(m => m.Session, Times.Exactly(2)); // called once in the constructor also
        }
        public void GetReadChannelSource_should_get_the_connection_source_from_the_read_binding(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_mockReadBinding.Object, _mockWriteBinding.Object);

            if (async)
            {
                subject.GetReadChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();

                _mockReadBinding.Verify(b => b.GetReadChannelSourceAsync(CancellationToken.None), Times.Once);
            }
            else
            {
                subject.GetReadChannelSource(CancellationToken.None);

                _mockReadBinding.Verify(b => b.GetReadChannelSource(CancellationToken.None), Times.Once);
            }
        }
        public void GetReadChannelSource_should_get_the_connection_source_from_the_read_binding(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            if (async)
            {
                subject.GetReadChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();

                _readBinding.Received().GetReadChannelSourceAsync(CancellationToken.None);
            }
            else
            {
                subject.GetReadChannelSource(CancellationToken.None);

                _readBinding.Received().GetReadChannelSource(CancellationToken.None);
            }
        }
        public void GetReadChannelSource_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);
            subject.Dispose();

            Action act;
            if (async)
            {
                act = () => subject.GetReadChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();
            }
            else
            {
                act = () => subject.GetReadChannelSource(CancellationToken.None);
            }

            act.ShouldThrow<ObjectDisposedException>();
        }
        public void GetReadChannelSource_should_get_the_connection_source_from_the_read_binding(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            if (async)
            {
                subject.GetReadChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();

                _readBinding.Received().GetReadChannelSourceAsync(CancellationToken.None);
            }
            else
            {
                subject.GetReadChannelSource(CancellationToken.None);

                _readBinding.Received().GetReadChannelSource(CancellationToken.None);
            }
        }
Ejemplo n.º 16
0
        public void GetWriteChannelSource_should_get_the_connection_source_from_the_write_binding(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_mockReadBinding.Object, _mockWriteBinding.Object);

            if (async)
            {
                subject.GetWriteChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();

                _mockWriteBinding.Verify(b => b.GetWriteChannelSourceAsync(CancellationToken.None), Times.Once);
            }
            else
            {
                subject.GetWriteChannelSource(CancellationToken.None);

                _mockWriteBinding.Verify(b => b.GetWriteChannelSource(CancellationToken.None), Times.Once);
            }
        }
Ejemplo n.º 17
0
        public void GetWriteChannelSource_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new SplitReadWriteBinding(_mockReadBinding.Object, _mockWriteBinding.Object);

            subject.Dispose();

            Action act;

            if (async)
            {
                act = () => subject.GetWriteChannelSourceAsync(CancellationToken.None).GetAwaiter().GetResult();
            }
            else
            {
                act = () => subject.GetWriteChannelSource(CancellationToken.None);
            }

            act.ShouldThrow <ObjectDisposedException>();
        }
Ejemplo n.º 18
0
        public void constructor_with_cluster_read_preference_and_session_should_initialize_instance()
        {
            var cluster        = new Mock <ICluster>().Object;
            var readPreference = ReadPreference.Secondary;
            var mockSession    = new Mock <ICoreSessionHandle>();
            var forkedSession  = new Mock <ICoreSessionHandle>().Object;

            mockSession.Setup(m => m.Fork()).Returns(forkedSession);

            var result = new SplitReadWriteBinding(cluster, readPreference, mockSession.Object);

            var readBinding = result._readBinding().Should().BeOfType <ReadPreferenceBinding>().Subject;

            readBinding._cluster().Should().BeSameAs(cluster);
            readBinding.ReadPreference.Should().BeSameAs(readPreference);
            readBinding.Session.Should().BeSameAs(mockSession.Object);

            var writeBinding = result._writeBinding().Should().BeOfType <WritableServerBinding>().Subject;

            writeBinding._cluster().Should().BeSameAs(cluster);
            writeBinding.Session.Should().BeSameAs(forkedSession);
        }
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.Dispose();

            _readBinding.Received().Dispose();
            _writeBinding.Received().Dispose();
        }
        public void GetWriteChannelSourceAsync_should_get_the_connection_source_from_the_write_binding()
        {
            var subject = new SplitReadWriteBinding(_readBinding, _writeBinding);

            subject.GetWriteChannelSourceAsync(CancellationToken.None);

            _writeBinding.Received().GetWriteChannelSourceAsync(CancellationToken.None);
        }
Ejemplo n.º 21
0
        public static IWriteBinding _writeBinding(this SplitReadWriteBinding obj)
        {
            var fieldInfo = typeof(SplitReadWriteBinding).GetField("_writeBinding", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IWriteBinding)fieldInfo.GetValue(obj));
        }
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new SplitReadWriteBinding(_mockReadBinding.Object, _mockWriteBinding.Object);

            subject.Dispose();

            _mockReadBinding.Verify(b => b.Dispose(), Times.Once);
            _mockWriteBinding.Verify(b => b.Dispose(), Times.Once);
        }