Example #1
0
        public void Dispose_should_call_dispose_on_connection_source()
        {
            var subject = new ChannelSourceReadWriteBinding(_channelSource, ReadPreference.Primary);

            subject.Dispose();

            _channelSource.Received().Dispose();
        }
Example #2
0
        public void Dispose_should_call_dispose_on_connection_source()
        {
            var subject = new ChannelSourceReadWriteBinding(_mockChannelSource.Object, ReadPreference.Primary, NoCoreSession.NewHandle());

            subject.Dispose();

            _mockChannelSource.Verify(f => f.Dispose(), Times.Once);
        }
Example #3
0
        public void Dispose_should_call_dispose_on_session()
        {
            var mockSession = new Mock <ICoreSessionHandle>();
            var subject     = new ChannelSourceReadWriteBinding(_mockChannelSource.Object, ReadPreference.Primary, mockSession.Object);

            subject.Dispose();

            mockSession.Verify(f => f.Dispose(), Times.Once);
        }
        public void GetWriteChannelSourceAsync_should_throw_if_disposed()
        {
            var subject = new ChannelSourceReadWriteBinding(_channelSource, ReadPreference.Primary);
            subject.Dispose();

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

            act.ShouldThrow<ObjectDisposedException>();
        }
        public void GetWriteChannelSourceAsync_should_throw_if_disposed()
        {
            var subject = new ChannelSourceReadWriteBinding(_channelSource, ReadPreference.Primary);

            subject.Dispose();

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

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void GetReadChannelSourceAsync_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new ChannelSourceReadWriteBinding(_channelSource, ReadPreference.Primary);
            subject.Dispose();

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

            act.ShouldThrow<ObjectDisposedException>();
        }
Example #7
0
        public void GetReadChannelSourceAsync_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new ChannelSourceReadWriteBinding(_mockChannelSource.Object, ReadPreference.Primary, 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_connection_source()
        {
            var subject = new ChannelSourceReadWriteBinding(_channelSource, ReadPreference.Primary);

            subject.Dispose();

            _channelSource.Received().Dispose();
        }
        public void Dispose_should_call_dispose_on_connection_source()
        {
            var subject = new ChannelSourceReadWriteBinding(_mockChannelSource.Object, ReadPreference.Primary);

            subject.Dispose();

            _mockChannelSource.Verify(f => f.Dispose(), Times.Once);
        }