Example #1
0
        public async stt::Task GetSettingRequestObjectAsync()
        {
            moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient> mockGrpcClient = new moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient>(moq::MockBehavior.Strict);
            GetSettingRequest request = new GetSettingRequest
            {
                SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                View        = SettingView.Basic,
            };
            Setting expectedResponse = new Setting
            {
                SettingName    = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                Metadata       = new SettingMetadata(),
                LocalValue     = new Value(),
                EffectiveValue = new Value(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetSettingAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Setting>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ResourceSettingsServiceClient client = new ResourceSettingsServiceClientImpl(mockGrpcClient.Object, null);
            Setting responseCallSettings         = await client.GetSettingAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Setting responseCancellationToken = await client.GetSettingAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
 /// <summary>Snippet for GetSetting</summary>
 public void GetSettingResourceNames()
 {
     // Snippet: GetSetting(SettingName, CallSettings)
     // Create client
     ResourceSettingsServiceClient resourceSettingsServiceClient = ResourceSettingsServiceClient.Create();
     // Initialize request argument(s)
     SettingName name = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]");
     // Make the request
     Setting response = resourceSettingsServiceClient.GetSetting(name);
     // End snippet
 }
Example #3
0
        /// <summary>Snippet for GetSettingAsync</summary>
        public async Task GetSettingResourceNamesAsync()
        {
            // Snippet: GetSettingAsync(SettingName, CallSettings)
            // Additional: GetSettingAsync(SettingName, CancellationToken)
            // Create client
            ResourceSettingsServiceClient resourceSettingsServiceClient = await ResourceSettingsServiceClient.CreateAsync();

            // Initialize request argument(s)
            SettingName name = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]");
            // Make the request
            Setting response = await resourceSettingsServiceClient.GetSettingAsync(name);

            // End snippet
        }
Example #4
0
 /// <summary>Snippet for GetSetting</summary>
 public void GetSettingRequestObject()
 {
     // Snippet: GetSetting(GetSettingRequest, CallSettings)
     // Create client
     ResourceSettingsServiceClient resourceSettingsServiceClient = ResourceSettingsServiceClient.Create();
     // Initialize request argument(s)
     GetSettingRequest request = new GetSettingRequest
     {
         SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
         View        = SettingView.Unspecified,
     };
     // Make the request
     Setting response = resourceSettingsServiceClient.GetSetting(request);
     // End snippet
 }
Example #5
0
        /// <summary>Snippet for GetSettingAsync</summary>
        public async Task GetSettingRequestObjectAsync()
        {
            // Snippet: GetSettingAsync(GetSettingRequest, CallSettings)
            // Additional: GetSettingAsync(GetSettingRequest, CancellationToken)
            // Create client
            ResourceSettingsServiceClient resourceSettingsServiceClient = await ResourceSettingsServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetSettingRequest request = new GetSettingRequest
            {
                SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                View        = SettingView.Unspecified,
            };
            // Make the request
            Setting response = await resourceSettingsServiceClient.GetSettingAsync(request);

            // End snippet
        }
Example #6
0
        public void GetSetting()
        {
            moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient> mockGrpcClient = new moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient>(moq::MockBehavior.Strict);
            GetSettingRequest request = new GetSettingRequest
            {
                SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
            };
            Setting expectedResponse = new Setting
            {
                SettingName    = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                Metadata       = new SettingMetadata(),
                LocalValue     = new Value(),
                EffectiveValue = new Value(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetSetting(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ResourceSettingsServiceClient client = new ResourceSettingsServiceClientImpl(mockGrpcClient.Object, null);
            Setting response = client.GetSetting(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }