public async stt::Task GetIamPolicyAsync()
        {
            moq::Mock <Subnetworks.SubnetworksClient> mockGrpcClient = new moq::Mock <Subnetworks.SubnetworksClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIamPolicySubnetworkRequest request = new GetIamPolicySubnetworkRequest
            {
                Region   = "regionedb20d96",
                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));
            SubnetworksClient client = new SubnetworksClientImpl(mockGrpcClient.Object, null);
            Policy            responseCallSettings = await client.GetIamPolicyAsync(request.Project, request.Region, request.Resource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

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

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIamPolicySubnetworkRequest request = new GetIamPolicySubnetworkRequest
            {
                Region   = "regionedb20d96",
                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);
            SubnetworksClient client   = new SubnetworksClientImpl(mockGrpcClient.Object, null);
            Policy            response = client.GetIamPolicy(request.Project, request.Region, request.Resource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 3
0
 /// <summary>Snippet for GetIamPolicy</summary>
 public void GetIamPolicyRequestObject()
 {
     // Snippet: GetIamPolicy(GetIamPolicySubnetworkRequest, CallSettings)
     // Create client
     SubnetworksClient subnetworksClient = SubnetworksClient.Create();
     // Initialize request argument(s)
     GetIamPolicySubnetworkRequest request = new GetIamPolicySubnetworkRequest
     {
         Region   = "",
         Resource = "",
         Project  = "",
         OptionsRequestedPolicyVersion = 0,
     };
     // Make the request
     Policy response = subnetworksClient.GetIamPolicy(request);
     // End snippet
 }
Ejemplo n.º 4
0
        /// <summary>Snippet for GetIamPolicyAsync</summary>
        public async Task GetIamPolicyRequestObjectAsync()
        {
            // Snippet: GetIamPolicyAsync(GetIamPolicySubnetworkRequest, CallSettings)
            // Additional: GetIamPolicyAsync(GetIamPolicySubnetworkRequest, CancellationToken)
            // Create client
            SubnetworksClient subnetworksClient = await SubnetworksClient.CreateAsync();

            // Initialize request argument(s)
            GetIamPolicySubnetworkRequest request = new GetIamPolicySubnetworkRequest
            {
                Region   = "",
                Resource = "",
                Project  = "",
                OptionsRequestedPolicyVersion = 0,
            };
            // Make the request
            Policy response = await subnetworksClient.GetIamPolicyAsync(request);

            // End snippet
        }