public async stt::Task GetGoogleServiceAccountRequestObjectAsync() { moq::Mock <StorageTransferService.StorageTransferServiceClient> mockGrpcClient = new moq::Mock <StorageTransferService.StorageTransferServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGoogleServiceAccountRequest request = new GetGoogleServiceAccountRequest { ProjectId = "project_id43ad98b0", }; GoogleServiceAccount expectedResponse = new GoogleServiceAccount { AccountEmail = "account_email01cc68b0", SubjectId = "subject_idd1a1abff", }; mockGrpcClient.Setup(x => x.GetGoogleServiceAccountAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GoogleServiceAccount>(stt::Task.FromResult(expectedResponse), null, null, null, null)); StorageTransferServiceClient client = new StorageTransferServiceClientImpl(mockGrpcClient.Object, null); GoogleServiceAccount responseCallSettings = await client.GetGoogleServiceAccountAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GoogleServiceAccount responseCancellationToken = await client.GetGoogleServiceAccountAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetGoogleServiceAccount</summary> public void GetGoogleServiceAccountRequestObject() { // Snippet: GetGoogleServiceAccount(GetGoogleServiceAccountRequest, CallSettings) // Create client StorageTransferServiceClient storageTransferServiceClient = StorageTransferServiceClient.Create(); // Initialize request argument(s) GetGoogleServiceAccountRequest request = new GetGoogleServiceAccountRequest { ProjectId = "", }; // Make the request GoogleServiceAccount response = storageTransferServiceClient.GetGoogleServiceAccount(request); // End snippet }
/// <summary>Snippet for GetGoogleServiceAccountAsync</summary> public async Task GetGoogleServiceAccountRequestObjectAsync() { // Snippet: GetGoogleServiceAccountAsync(GetGoogleServiceAccountRequest, CallSettings) // Additional: GetGoogleServiceAccountAsync(GetGoogleServiceAccountRequest, CancellationToken) // Create client StorageTransferServiceClient storageTransferServiceClient = await StorageTransferServiceClient.CreateAsync(); // Initialize request argument(s) GetGoogleServiceAccountRequest request = new GetGoogleServiceAccountRequest { ProjectId = "", }; // Make the request GoogleServiceAccount response = await storageTransferServiceClient.GetGoogleServiceAccountAsync(request); // End snippet }
public void GetGoogleServiceAccountRequestObject() { moq::Mock <StorageTransferService.StorageTransferServiceClient> mockGrpcClient = new moq::Mock <StorageTransferService.StorageTransferServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGoogleServiceAccountRequest request = new GetGoogleServiceAccountRequest { ProjectId = "project_id43ad98b0", }; GoogleServiceAccount expectedResponse = new GoogleServiceAccount { AccountEmail = "account_email01cc68b0", SubjectId = "subject_idd1a1abff", }; mockGrpcClient.Setup(x => x.GetGoogleServiceAccount(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); StorageTransferServiceClient client = new StorageTransferServiceClientImpl(mockGrpcClient.Object, null); GoogleServiceAccount response = client.GetGoogleServiceAccount(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }