Exemple #1
0
        public async stt::Task SetIamPolicyAsync()
        {
            moq::Mock <Snapshots.SnapshotsClient> mockGrpcClient = new moq::Mock <Snapshots.SnapshotsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            SetIamPolicySnapshotRequest request = new SetIamPolicySnapshotRequest
            {
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
                GlobalSetPolicyRequestResource = new GlobalSetPolicyRequest(),
            };
            Policy expectedResponse = new Policy
            {
                Etag         = "etage8ad7218",
                Rules        = { new Rule(), },
                AuditConfigs = { new AuditConfig(), },
                Version      = 271578922,
                Bindings     = { new Binding(), },
                IamOwned     = false,
            };

            mockGrpcClient.Setup(x => x.SetIamPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            SnapshotsClient client = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            Policy          responseCallSettings = await client.SetIamPolicyAsync(request.Project, request.Resource, request.GlobalSetPolicyRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public void SetIamPolicy()
        {
            moq::Mock <Snapshots.SnapshotsClient> mockGrpcClient = new moq::Mock <Snapshots.SnapshotsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            SetIamPolicySnapshotRequest request = new SetIamPolicySnapshotRequest
            {
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
                GlobalSetPolicyRequestResource = new GlobalSetPolicyRequest(),
            };
            Policy expectedResponse = new Policy
            {
                Etag         = "etage8ad7218",
                Rules        = { new Rule(), },
                AuditConfigs = { new AuditConfig(), },
                Version      = 271578922,
                Bindings     = { new Binding(), },
                IamOwned     = false,
            };

            mockGrpcClient.Setup(x => x.SetIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SnapshotsClient client   = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            Policy          response = client.SetIamPolicy(request.Project, request.Resource, request.GlobalSetPolicyRequestResource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for SetIamPolicy</summary>
 public void SetIamPolicyRequestObject()
 {
     // Snippet: SetIamPolicy(SetIamPolicySnapshotRequest, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     SetIamPolicySnapshotRequest request = new SetIamPolicySnapshotRequest
     {
         Resource = "",
         Project  = "",
         GlobalSetPolicyRequestResource = new GlobalSetPolicyRequest(),
     };
     // Make the request
     Policy response = snapshotsClient.SetIamPolicy(request);
     // End snippet
 }
        /// <summary>Snippet for SetIamPolicyAsync</summary>
        public async Task SetIamPolicyRequestObjectAsync()
        {
            // Snippet: SetIamPolicyAsync(SetIamPolicySnapshotRequest, CallSettings)
            // Additional: SetIamPolicyAsync(SetIamPolicySnapshotRequest, CancellationToken)
            // Create client
            SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();

            // Initialize request argument(s)
            SetIamPolicySnapshotRequest request = new SetIamPolicySnapshotRequest
            {
                Resource = "",
                Project  = "",
                GlobalSetPolicyRequestResource = new GlobalSetPolicyRequest(),
            };
            // Make the request
            Policy response = await snapshotsClient.SetIamPolicyAsync(request);

            // End snippet
        }