public async stt::Task GetResourceRequestObjectAsync() { moq::Mock <GatewayService.GatewayServiceClient> mockGrpcClient = new moq::Mock <GatewayService.GatewayServiceClient>(moq::MockBehavior.Strict); ga::HttpBody request = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; ga::HttpBody expectedResponse = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; mockGrpcClient.Setup(x => x.GetResourceAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ga::HttpBody>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GatewayServiceClient client = new GatewayServiceClientImpl(mockGrpcClient.Object, null); ga::HttpBody responseCallSettings = await client.GetResourceAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ga::HttpBody responseCancellationToken = await client.GetResourceAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void PostResourceRequestObject() { moq::Mock <GatewayService.GatewayServiceClient> mockGrpcClient = new moq::Mock <GatewayService.GatewayServiceClient>(moq::MockBehavior.Strict); ga::HttpBody request = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; ga::HttpBody expectedResponse = new ga::HttpBody { ContentType = "content_type085be0ea", Data = proto::ByteString.CopyFromUtf8("data387f778d"), Extensions = { new wkt::Any(), }, }; mockGrpcClient.Setup(x => x.PostResource(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GatewayServiceClient client = new GatewayServiceClientImpl(mockGrpcClient.Object, null); ga::HttpBody response = client.PostResource(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }