public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new WritableServerBinding(_cluster);

            subject.Dispose();

            _cluster.DidNotReceive().Dispose();
        }
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new WritableServerBinding(_mockCluster.Object);

            subject.Dispose();

            _mockCluster.Verify(c => c.Dispose(), Times.Never);
        }
        public void GetWriteConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new WritableServerBinding(_cluster);
            subject.Dispose();

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

            act.ShouldThrow<ObjectDisposedException>();
        }
        public void Dispose_should_call_dispose_on_owned_resources()
        {
            var mockSession = new Mock <ICoreSessionHandle>();
            var subject     = new WritableServerBinding(_mockCluster.Object, mockSession.Object);

            subject.Dispose();

            _mockCluster.Verify(c => c.Dispose(), Times.Never);
            mockSession.Verify(m => m.Dispose(), Times.Once);
        }
        public void GetWriteConnectionSourceAsync_should_throw_if_disposed()
        {
            var subject = new WritableServerBinding(_cluster);

            subject.Dispose();

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

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void GetReadChannelSource_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new WritableServerBinding(_mockCluster.Object);
            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_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new WritableServerBinding(_mockCluster.Object, NoCoreSession.NewHandle());

            subject.Dispose();

            Action act;

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

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new WritableServerBinding(_cluster);

            subject.Dispose();

            _cluster.DidNotReceive().Dispose();
        }
        public void Dispose_should_call_dispose_on_read_binding_and_write_binding()
        {
            var subject = new WritableServerBinding(_mockCluster.Object);

            subject.Dispose();

            _mockCluster.Verify(c => c.Dispose(), Times.Never);
        }