public async stt::Task CreateAutoscalingPolicyRequestObjectAsync() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id74b70bb8", AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), BasicAlgorithm = new BasicAutoscalingAlgorithm(), WorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), SecondaryWorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AutoscalingPolicy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy responseCallSettings = await client.CreateAutoscalingPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AutoscalingPolicy responseCancellationToken = await client.CreateAutoscalingPolicyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetAutoscalingPolicyResourceNames() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); GetAutoscalingPolicyRequest request = new GetAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id74b70bb8", AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), BasicAlgorithm = new BasicAutoscalingAlgorithm(), WorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), SecondaryWorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.GetAutoscalingPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy response = client.GetAutoscalingPolicy(request.AutoscalingPolicyName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetAutoscalingPolicy</summary> public void GetAutoscalingPolicyResourceNames() { // Snippet: GetAutoscalingPolicy(AutoscalingPolicyName, CallSettings) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = AutoscalingPolicyServiceClient.Create(); // Initialize request argument(s) AutoscalingPolicyName name = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"); // Make the request AutoscalingPolicy response = autoscalingPolicyServiceClient.GetAutoscalingPolicy(name); // End snippet }
/// <summary>Snippet for DeleteAutoscalingPolicyAsync</summary> public async Task DeleteAutoscalingPolicyResourceNamesAsync() { // Snippet: DeleteAutoscalingPolicyAsync(AutoscalingPolicyName, CallSettings) // Additional: DeleteAutoscalingPolicyAsync(AutoscalingPolicyName, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) AutoscalingPolicyName name = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"); // Make the request await autoscalingPolicyServiceClient.DeleteAutoscalingPolicyAsync(name); // End snippet }
/// <summary>Snippet for GetAutoscalingPolicy</summary> public void GetAutoscalingPolicyRequestObject() { // Snippet: GetAutoscalingPolicy(GetAutoscalingPolicyRequest, CallSettings) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = AutoscalingPolicyServiceClient.Create(); // Initialize request argument(s) GetAutoscalingPolicyRequest request = new GetAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; // Make the request AutoscalingPolicy response = autoscalingPolicyServiceClient.GetAutoscalingPolicy(request); // End snippet }
public void DeleteAutoscalingPolicyResourceNames() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); DeleteAutoscalingPolicyRequest request = new DeleteAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteAutoscalingPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); client.DeleteAutoscalingPolicy(request.AutoscalingPolicyName); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetAutoscalingPolicyAsync</summary> public async Task GetAutoscalingPolicyRequestObjectAsync() { // Snippet: GetAutoscalingPolicyAsync(GetAutoscalingPolicyRequest, CallSettings) // Additional: GetAutoscalingPolicyAsync(GetAutoscalingPolicyRequest, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) GetAutoscalingPolicyRequest request = new GetAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.GetAutoscalingPolicyAsync(request); // End snippet }
public async stt::Task DeleteAutoscalingPolicyResourceNamesAsync() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); DeleteAutoscalingPolicyRequest request = new DeleteAutoscalingPolicyRequest { AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteAutoscalingPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteAutoscalingPolicyAsync(request.AutoscalingPolicyName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteAutoscalingPolicyAsync(request.AutoscalingPolicyName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public void CreateAutoscalingPolicyRequestObject() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id74b70bb8", AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), BasicAlgorithm = new BasicAutoscalingAlgorithm(), WorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), SecondaryWorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy response = client.CreateAutoscalingPolicy(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }