Ejemplo n.º 1
0
        public async stt::Task GetIamPolicyAsync()
        {
            moq::Mock <NodeGroups.NodeGroupsClient> mockGrpcClient = new moq::Mock <NodeGroups.NodeGroupsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForZoneOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIamPolicyNodeGroupRequest request = new GetIamPolicyNodeGroupRequest
            {
                Zone     = "zone255f4ea8",
                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));
            NodeGroupsClient client = new NodeGroupsClientImpl(mockGrpcClient.Object, null);
            Policy           responseCallSettings = await client.GetIamPolicyAsync(request.Project, request.Zone, request.Resource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetIamPolicy()
        {
            moq::Mock <NodeGroups.NodeGroupsClient> mockGrpcClient = new moq::Mock <NodeGroups.NodeGroupsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForZoneOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIamPolicyNodeGroupRequest request = new GetIamPolicyNodeGroupRequest
            {
                Zone     = "zone255f4ea8",
                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);
            NodeGroupsClient client   = new NodeGroupsClientImpl(mockGrpcClient.Object, null);
            Policy           response = client.GetIamPolicy(request.Project, request.Zone, request.Resource);

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

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

            // End snippet
        }