/// <summary>Snippet for GenerateUploadUrl</summary> public void GenerateUploadUrlRequestObject() { // Snippet: GenerateUploadUrl(GenerateUploadUrlRequest, CallSettings) // Create client CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create(); // Initialize request argument(s) GenerateUploadUrlRequest request = new GenerateUploadUrlRequest { Parent = "", }; // Make the request GenerateUploadUrlResponse response = cloudFunctionsServiceClient.GenerateUploadUrl(request); // End snippet }
/// <summary>Snippet for GenerateUploadUrlAsync</summary> public async Task GenerateUploadUrlRequestObjectAsync() { // Snippet: GenerateUploadUrlAsync(GenerateUploadUrlRequest, CallSettings) // Additional: GenerateUploadUrlAsync(GenerateUploadUrlRequest, CancellationToken) // Create client CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync(); // Initialize request argument(s) GenerateUploadUrlRequest request = new GenerateUploadUrlRequest { Parent = "", }; // Make the request GenerateUploadUrlResponse response = await cloudFunctionsServiceClient.GenerateUploadUrlAsync(request); // End snippet }
public void GenerateUploadUrlRequestObject() { moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient> mockGrpcClient = new moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GenerateUploadUrlRequest request = new GenerateUploadUrlRequest { Parent = "parent7858e4d0", }; GenerateUploadUrlResponse expectedResponse = new GenerateUploadUrlResponse { UploadUrl = "upload_url333fbc45", }; mockGrpcClient.Setup(x => x.GenerateUploadUrl(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CloudFunctionsServiceClient client = new CloudFunctionsServiceClientImpl(mockGrpcClient.Object, null); GenerateUploadUrlResponse response = client.GenerateUploadUrl(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GenerateUploadUrlRequestObjectAsync() { moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient> mockGrpcClient = new moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GenerateUploadUrlRequest request = new GenerateUploadUrlRequest { Parent = "parent7858e4d0", }; GenerateUploadUrlResponse expectedResponse = new GenerateUploadUrlResponse { UploadUrl = "upload_url333fbc45", }; mockGrpcClient.Setup(x => x.GenerateUploadUrlAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateUploadUrlResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CloudFunctionsServiceClient client = new CloudFunctionsServiceClientImpl(mockGrpcClient.Object, null); GenerateUploadUrlResponse responseCallSettings = await client.GenerateUploadUrlAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GenerateUploadUrlResponse responseCancellationToken = await client.GenerateUploadUrlAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }