Beispiel #1
0
        public void GetChannelAsync_should_get_connection_from_server()
        {
            var subject = new ServerChannelSource(_server);

            subject.GetChannelAsync(CancellationToken.None);

            _server.Received().GetChannelAsync(CancellationToken.None);
        }
Beispiel #2
0
        public void Session_should_return_expected_result()
        {
            var session = new Mock <ICoreSessionHandle>().Object;
            var subject = new ServerChannelSource(_mockServer.Object, session);

            var result = subject.Session;

            result.Should().BeSameAs(session);
        }
Beispiel #3
0
        public void Dispose_should_dispose_session()
        {
            var mockSession = new Mock <ICoreSessionHandle>();
            var subject     = new ServerChannelSource(_mockServer.Object, mockSession.Object);

            subject.Dispose();

            mockSession.Verify(m => m.Dispose(), Times.Once);
        }
Beispiel #4
0
        public void GetChannelAsync_should_throw_if_disposed()
        {
            var subject = new ServerChannelSource(_server);

            subject.Dispose();

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

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void ServerDescription_should_return_description_of_server()
        {
            var subject = new ServerChannelSource(_mockServer.Object);

            var desc = ServerDescriptionHelper.Disconnected(new ClusterId());

            _mockServer.SetupGet(s => s.Description).Returns(desc);

            var result = subject.ServerDescription;

            result.Should().BeSameAs(desc);
        }
        public void ServerDescription_should_return_description_of_server()
        {
            var subject = new ServerChannelSource(_server);

            var desc = ServerDescriptionHelper.Disconnected(new ClusterId());

            _server.Description.Returns(desc);

            var result = subject.ServerDescription;

            result.Should().BeSameAs(desc);
        }
Beispiel #7
0
        public void ServerDescription_should_return_description_of_server()
        {
            var session = new Mock <ICoreSessionHandle>().Object;
            var subject = new ServerChannelSource(_mockServer.Object, session);

            var desc = ServerDescriptionHelper.Disconnected(new ClusterId());

            _mockServer.SetupGet(s => s.Description).Returns(desc);

            var result = subject.ServerDescription;

            result.Should().BeSameAs(desc);
        }
        public void GetChannel_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_mockServer.Object);
            subject.Dispose();

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

            act.ShouldThrow<ObjectDisposedException>();
        }
        public void GetChannel_should_get_connection_from_server(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_server);

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

                _server.Received().GetChannelAsync(CancellationToken.None);
            }
            else
            {
                subject.GetChannel(CancellationToken.None);

                _server.Received().GetChannel(CancellationToken.None);
            }
        }
Beispiel #10
0
        public void GetChannel_should_get_connection_from_server(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_mockServer.Object);

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

                _mockServer.Verify(s => s.GetChannelAsync(CancellationToken.None), Times.Once);
            }
            else
            {
                subject.GetChannel(CancellationToken.None);

                _mockServer.Verify(s => s.GetChannel(CancellationToken.None), Times.Once);
            }
        }
        public void GetChannel_should_throw_if_disposed(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_server);

            subject.Dispose();

            Action act;

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

            act.ShouldThrow <ObjectDisposedException>();
        }
        public void GetChannel_should_get_connection_from_server(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_mockServer.Object);

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

                _mockServer.Verify(s => s.GetChannelAsync(CancellationToken.None), Times.Once);
            }
            else
            {
                subject.GetChannel(CancellationToken.None);

                _mockServer.Verify(s => s.GetChannel(CancellationToken.None), Times.Once);
            }
        }
        public void GetChannel_should_get_connection_from_server(
            [Values(false, true)]
            bool async)
        {
            var subject = new ServerChannelSource(_server);

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

                _server.Received().GetChannelAsync(CancellationToken.None);
            }
            else
            {
                subject.GetChannel(CancellationToken.None);

                _server.Received().GetChannel(CancellationToken.None);
            }
        }