Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 3
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>();
        }
Ejemplo n.º 5
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_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);
            }
        }