Exemplo n.º 1
0
        public async stt::Task TestIamPermissionsAsync()
        {
            moq::Mock <Disks.DisksClient> mockGrpcClient = new moq::Mock <Disks.DisksClient>(moq::MockBehavior.Strict);

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void TestIamPermissions()
        {
            moq::Mock <Disks.DisksClient> mockGrpcClient = new moq::Mock <Disks.DisksClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForZoneOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            TestIamPermissionsDiskRequest request = new TestIamPermissionsDiskRequest
            {
                Zone     = "zone255f4ea8",
                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);
            DisksClient             client   = new DisksClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Zone, request.Resource, request.TestPermissionsRequestResource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 3
0
 /// <summary>Snippet for TestIamPermissions</summary>
 public void TestIamPermissionsRequestObject()
 {
     // Snippet: TestIamPermissions(TestIamPermissionsDiskRequest, CallSettings)
     // Create client
     DisksClient disksClient = DisksClient.Create();
     // Initialize request argument(s)
     TestIamPermissionsDiskRequest request = new TestIamPermissionsDiskRequest
     {
         Zone = "",
         TestPermissionsRequestResource = new TestPermissionsRequest(),
         Resource = "",
         Project  = "",
     };
     // Make the request
     TestPermissionsResponse response = disksClient.TestIamPermissions(request);
     // End snippet
 }
Exemplo n.º 4
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsRequestObjectAsync()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsDiskRequest, CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsDiskRequest, CancellationToken)
            // Create client
            DisksClient disksClient = await DisksClient.CreateAsync();

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

            // End snippet
        }