public async stt::Task TestIamPermissionsAsync()
        {
            moq::Mock <ResourcePolicies.ResourcePoliciesClient> mockGrpcClient = new moq::Mock <ResourcePolicies.ResourcePoliciesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            TestIamPermissionsResourcePolicyRequest request = new TestIamPermissionsResourcePolicyRequest
            {
                Region   = "regionedb20d96",
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
                TestPermissionsRequestResource = new TestPermissionsRequest(),
            };
            TestPermissionsResponse expectedResponse = new TestPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TestPermissionsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ResourcePoliciesClient  client = new ResourcePoliciesClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TestPermissionsResponse responseCancellationToken = await client.TestIamPermissionsAsync(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void TestIamPermissions()
        {
            moq::Mock <ResourcePolicies.ResourcePoliciesClient> mockGrpcClient = new moq::Mock <ResourcePolicies.ResourcePoliciesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            TestIamPermissionsResourcePolicyRequest request = new TestIamPermissionsResourcePolicyRequest
            {
                Region   = "regionedb20d96",
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
                TestPermissionsRequestResource = new TestPermissionsRequest(),
            };
            TestPermissionsResponse expectedResponse = new TestPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ResourcePoliciesClient  client   = new ResourcePoliciesClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #3
0
 /// <summary>Snippet for TestIamPermissions</summary>
 public void TestIamPermissionsRequestObject()
 {
     // Snippet: TestIamPermissions(TestIamPermissionsResourcePolicyRequest, CallSettings)
     // Create client
     ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.Create();
     // Initialize request argument(s)
     TestIamPermissionsResourcePolicyRequest request = new TestIamPermissionsResourcePolicyRequest
     {
         Region = "",
         TestPermissionsRequestResource = new TestPermissionsRequest(),
         Resource = "",
         Project  = "",
     };
     // Make the request
     TestPermissionsResponse response = resourcePoliciesClient.TestIamPermissions(request);
     // End snippet
 }
Пример #4
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsRequestObjectAsync()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsResourcePolicyRequest, CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsResourcePolicyRequest, CancellationToken)
            // Create client
            ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsResourcePolicyRequest request = new TestIamPermissionsResourcePolicyRequest
            {
                Region = "",
                TestPermissionsRequestResource = new TestPermissionsRequest(),
                Resource = "",
                Project  = "",
            };
            // Make the request
            TestPermissionsResponse response = await resourcePoliciesClient.TestIamPermissionsAsync(request);

            // End snippet
        }