示例#1
0
        public async Task SendValidRequest_WithConnectionOptions(TestServerEndpointName endpointName, string?version, bool success)
        {
            SetExpectedErrorsFilter(writeContext =>
            {
                return(!success);
            });

            // Arrage
            Version.TryParse(version, out var v);
            var channel = CreateGrpcWebChannel(endpointName, v);

            var client = new EchoService.EchoServiceClient(channel);

            // Act
            var call = client.EchoAsync(new EchoRequest {
                Message = "test"
            }).ResponseAsync.DefaultTimeout();

            // Assert
            if (success)
            {
                Assert.AreEqual("test", (await call).Message);
            }
            else
            {
                await ExceptionAssert.ThrowsAsync <RpcException>(async() => await call);
            }
        }
示例#2
0
        private HttpClient CreateGrpcWebClient(TestServerEndpointName endpointName, Version?version)
        {
            GrpcWebHandler grpcWebHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb);

            grpcWebHandler.HttpVersion = version;

            return(Fixture.CreateClient(endpointName, grpcWebHandler));
        }
示例#3
0
        private GrpcChannel CreateGrpcWebChannel(TestServerEndpointName endpointName, Version?version)
        {
            var httpClient = CreateGrpcWebClient(endpointName, version);
            var channel    = GrpcChannel.ForAddress(httpClient.BaseAddress !, new GrpcChannelOptions
            {
                HttpClient    = httpClient,
                LoggerFactory = LoggerFactory
            });

            return(channel);
        }
示例#4
0
        protected GrpcWebFunctionalTestBase(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
        {
            GrpcTestMode = grpcTestMode;
            EndpointName = endpointName;

#if NET6_0_OR_GREATER
            if (endpointName == TestServerEndpointName.Http3WithTls &&
                !RequireHttp3Attribute.IsSupported(out var message))
            {
                Assert.Ignore(message);
            }
#endif
        }
示例#5
0
        private GrpcChannel CreateGrpcWebChannel(TestServerEndpointName endpointName, Version?version)
        {
            var grpcWebHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb);

            grpcWebHandler.HttpVersion = version;

            var httpClient = Fixture.CreateClient(endpointName, grpcWebHandler);
            var channel    = GrpcChannel.ForAddress(httpClient.BaseAddress !, new GrpcChannelOptions
            {
                HttpClient    = httpClient,
                LoggerFactory = LoggerFactory
            });

            return(channel);
        }
示例#6
0
        public async Task SendValidRequest_WithConnectionOptions(TestServerEndpointName endpointName, string?version, bool success)
        {
#if NET6_0_OR_GREATER
            if (endpointName == TestServerEndpointName.Http3WithTls &&
                !RequireHttp3Attribute.IsSupported(out var message))
            {
                Assert.Ignore(message);
            }
#endif

            SetExpectedErrorsFilter(writeContext =>
            {
                return(!success);
            });

            // Arrage
            Version.TryParse(version, out var v);
            var channel = CreateGrpcWebChannel(endpointName, v);

            var client = new EchoService.EchoServiceClient(channel);

            // Act
            var call = client.EchoAsync(new EchoRequest {
                Message = "test"
            }).ResponseAsync.DefaultTimeout();

            // Assert
            if (success)
            {
                Assert.AreEqual("test", (await call.DefaultTimeout()).Message);
            }
            else
            {
                await ExceptionAssert.ThrowsAsync <RpcException>(async() => await call).DefaultTimeout();
            }
        }
示例#7
0
 public IssueTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }
示例#8
0
 public TrailerMetadataTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }
示例#9
0
 public ServerStreamingMethodTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }
 public UnaryMethodTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }
示例#11
0
 public DeadlineTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }
示例#12
0
 public abstract string GetUrl(TestServerEndpointName endpointName);
 protected GrpcWebFunctionalTestBase(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
 {
     _grpcTestMode = grpcTestMode;
     _endpointName = endpointName;
 }
示例#14
0
 public ClientFactoryTests(GrpcTestMode grpcTestMode, TestServerEndpointName endpointName)
     : base(grpcTestMode, endpointName)
 {
 }