/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetTargetPoolRequest, CallSettings) // Create client TargetPoolsClient targetPoolsClient = TargetPoolsClient.Create(); // Initialize request argument(s) GetTargetPoolRequest request = new GetTargetPoolRequest { TargetPool = "", Region = "", Project = "", }; // Make the request TargetPool response = targetPoolsClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetTargetPoolRequest, CallSettings) // Additional: GetAsync(GetTargetPoolRequest, CancellationToken) // Create client TargetPoolsClient targetPoolsClient = await TargetPoolsClient.CreateAsync(); // Initialize request argument(s) GetTargetPoolRequest request = new GetTargetPoolRequest { TargetPool = "", Region = "", Project = "", }; // Make the request TargetPool response = await targetPoolsClient.GetAsync(request); // End snippet }
public async stt::Task GetRequestObjectAsync() { moq::Mock <TargetPools.TargetPoolsClient> mockGrpcClient = new moq::Mock <TargetPools.TargetPoolsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTargetPoolRequest request = new GetTargetPoolRequest { TargetPool = "target_pool65e437ac", Region = "regionedb20d96", Project = "projectaa6ff846", }; TargetPool expectedResponse = new TargetPool { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", Instances = { "instances5432a96f", }, CreationTimestamp = "creation_timestamp235e59a1", BackupPool = "backup_pool2446601c", Region = "regionedb20d96", FailoverRatio = -7.1869584E+17F, Description = "description2cf9da67", HealthChecks = { "health_checksedb1f3f8", }, SelfLink = "self_link7e87f12d", SessionAffinity = "session_affinitye702dadf", }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TargetPool>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TargetPoolsClient client = new TargetPoolsClientImpl(mockGrpcClient.Object, null); TargetPool responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TargetPool responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetRequestObject() { moq::Mock <TargetPools.TargetPoolsClient> mockGrpcClient = new moq::Mock <TargetPools.TargetPoolsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTargetPoolRequest request = new GetTargetPoolRequest { TargetPool = "target_pool65e437ac", Region = "regionedb20d96", Project = "projectaa6ff846", }; TargetPool expectedResponse = new TargetPool { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", Instances = { "instances5432a96f", }, CreationTimestamp = "creation_timestamp235e59a1", BackupPool = "backup_pool2446601c", Region = "regionedb20d96", FailoverRatio = -7.1869584E+17F, Description = "description2cf9da67", HealthChecks = { "health_checksedb1f3f8", }, SelfLink = "self_link7e87f12d", SessionAffinity = TargetPool.Types.SessionAffinity.GeneratedCookie, }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TargetPoolsClient client = new TargetPoolsClientImpl(mockGrpcClient.Object, null); TargetPool response = client.Get(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }