public async stt::Task GetIamPolicyAsync() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); GetIamPolicyLicenseRequest request = new GetIamPolicyLicenseRequest { Resource = "resource164eab96", Project = "projectaa6ff846", }; Policy expectedResponse = new Policy { Etag = "etage8ad7218", Rules = { new Rule(), }, AuditConfigs = { new AuditConfig(), }, Version = 271578922, Bindings = { new Binding(), }, IamOwned = false, }; mockGrpcClient.Setup(x => x.GetIamPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); Policy responseCallSettings = await client.GetIamPolicyAsync(request.Project, request.Resource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Policy responseCancellationToken = await client.GetIamPolicyAsync(request.Project, request.Resource, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetIamPolicy() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); GetIamPolicyLicenseRequest request = new GetIamPolicyLicenseRequest { Resource = "resource164eab96", Project = "projectaa6ff846", }; Policy expectedResponse = new Policy { Etag = "etage8ad7218", Rules = { new Rule(), }, AuditConfigs = { new AuditConfig(), }, Version = 271578922, Bindings = { new Binding(), }, IamOwned = false, }; mockGrpcClient.Setup(x => x.GetIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); Policy response = client.GetIamPolicy(request.Project, request.Resource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetIamPolicy</summary> public void GetIamPolicyRequestObject() { // Snippet: GetIamPolicy(GetIamPolicyLicenseRequest, CallSettings) // Create client LicensesClient licensesClient = LicensesClient.Create(); // Initialize request argument(s) GetIamPolicyLicenseRequest request = new GetIamPolicyLicenseRequest { Resource = "", Project = "", OptionsRequestedPolicyVersion = 0, }; // Make the request Policy response = licensesClient.GetIamPolicy(request); // End snippet }
/// <summary>Snippet for GetIamPolicyAsync</summary> public async Task GetIamPolicyRequestObjectAsync() { // Snippet: GetIamPolicyAsync(GetIamPolicyLicenseRequest, CallSettings) // Additional: GetIamPolicyAsync(GetIamPolicyLicenseRequest, CancellationToken) // Create client LicensesClient licensesClient = await LicensesClient.CreateAsync(); // Initialize request argument(s) GetIamPolicyLicenseRequest request = new GetIamPolicyLicenseRequest { Resource = "", Project = "", OptionsRequestedPolicyVersion = 0, }; // Make the request Policy response = await licensesClient.GetIamPolicyAsync(request); // End snippet }