Пример #1
0
        public void SameEndpoint_SameChannel()
        {
            var pool = new ChannelPool(ServiceMetadata);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(Grpc, fixture.Endpoint, GrpcChannelOptions.Empty);
                var channel2 = pool.GetChannel(Grpc, fixture.Endpoint, GrpcChannelOptions.Empty);
                Assert.Same(channel1, channel2);
            }
        }
Пример #2
0
        public void DifferentEndpoint_DifferentChannel()
        {
            var pool = new ChannelPool(ServiceMetadata);

            using (TestServiceFixture fixture1 = new TestServiceFixture(), fixture2 = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(Grpc, fixture1.Endpoint, GrpcChannelOptions.Empty);
                var channel2 = pool.GetChannel(Grpc, fixture2.Endpoint, GrpcChannelOptions.Empty);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #3
0
        public void DifferentEndpoint_DifferentChannel()
        {
            var pool = new ChannelPool(EmptyScopes);

            using (TestServiceFixture fixture1 = new TestServiceFixture(), fixture2 = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(fixture1.Endpoint);
                var channel2 = pool.GetChannel(fixture2.Endpoint);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #4
0
        public void SameEndpoint_SameChannel()
        {
            var pool = new ChannelPool(EmptyScopes);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(fixture.Endpoint);
                var channel2 = pool.GetChannel(fixture.Endpoint);
                Assert.Same(channel1, channel2);
            }
        }
Пример #5
0
        public void ShutdownAsync_EmptiesPool()
        {
            var pool = new ChannelPool(ServiceMetadata);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(Grpc, fixture.Endpoint, GrpcChannelOptions.Empty);
                // Note: *not* waiting for this to complete.
                pool.ShutdownChannelsAsync();
                var channel2 = pool.GetChannel(Grpc, fixture.Endpoint, GrpcChannelOptions.Empty);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #6
0
        public async Task ShutdownAsync_ShutsDownChannel()
        {
            var pool = new ChannelPool(ServiceMetadata);

            using (var fixture = new TestServiceFixture())
            {
                var channel = (Channel)pool.GetChannel(Grpc, fixture.Endpoint, GrpcChannelOptions.Empty);
                Assert.NotEqual(ChannelState.Shutdown, channel.State);
                await pool.ShutdownChannelsAsync();

                Assert.Equal(ChannelState.Shutdown, channel.State);
            }
        }
Пример #7
0
        public void DifferentOptions_DifferentChannel()
        {
            var options1 = GrpcChannelOptions.Empty.WithCustomOption("x", 5);
            var options2 = GrpcChannelOptions.Empty.WithCustomOption("x", 6);
            var pool     = new ChannelPool(ServiceMetadata);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(Grpc, fixture.Endpoint, options1);
                var channel2 = pool.GetChannel(Grpc, fixture.Endpoint, options2);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #8
0
        public void SameOptions_SameChannel()
        {
            var options1 = GrpcChannelOptions.Empty.WithCustomOption("x", 5);
            var options2 = GrpcChannelOptions.Empty.WithCustomOption("x", 5);
            var pool     = new ChannelPool(EmptyScopes);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(Grpc, fixture.Endpoint, options1);
                var channel2 = pool.GetChannel(Grpc, fixture.Endpoint, options2);
                Assert.Same(channel1, channel2);
            }
        }
Пример #9
0
        public void ShutdownAsync_EmptiesPool()
        {
            var pool = new ChannelPool(EmptyScopes);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(fixture.Endpoint);
                // Note: *not* waiting for this to complete.
                pool.ShutdownChannelsAsync();
                var channel2 = pool.GetChannel(fixture.Endpoint);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #10
0
        public async Task ShutdownAsync_ShutsDownChannel()
        {
            var pool = new ChannelPool(EmptyScopes);

            using (var fixture = new TestServiceFixture())
            {
                var channel = pool.GetChannel(fixture.Endpoint);
                Assert.NotEqual(ChannelState.Shutdown, channel.State);
                await pool.ShutdownChannelsAsync();

                Assert.Equal(ChannelState.Shutdown, channel.State);
            }
        }
Пример #11
0
        public void DifferentOptions_DifferentChannel()
        {
            var options1 = new[] { new ChannelOption("x", 5) };
            var options2 = new[] { new ChannelOption("x", 6) };
            var pool     = new ChannelPool(EmptyScopes);

            using (var fixture = new TestServiceFixture())
            {
                var channel1 = pool.GetChannel(fixture.Endpoint, options1);
                var channel2 = pool.GetChannel(fixture.Endpoint, options2);
                Assert.NotSame(channel1, channel2);
            }
        }
Пример #12
0
 public GrpcAdapterTest(TestServiceFixture fixture) => _fixture = fixture;
 public GrpcNetClientAdapterTest(TestServiceFixture fixture) => _fixture = fixture;