예제 #1
0
        public async stt::Task TestIamPermissionsAsync()
        {
            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);
            TestIamPermissionsSnapshotRequest request = new TestIamPermissionsSnapshotRequest
            {
                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));
            SnapshotsClient         client = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.Project, request.Resource, request.TestPermissionsRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #2
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();
        }
예제 #3
0
        public void TestIamPermissions()
        {
            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);
            TestIamPermissionsSnapshotRequest request = new TestIamPermissionsSnapshotRequest
            {
                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);
            SnapshotsClient         client   = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Resource, request.TestPermissionsRequestResource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #4
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();
        }
예제 #5
0
        public void GetRequestObject()
        {
            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);
            GetSnapshotRequest request = new GetSnapshotRequest
            {
                Project  = "projectaa6ff846",
                Snapshot = "snapshotded322c3",
            };
            Snapshot expectedResponse = new Snapshot
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp     = "creation_timestamp235e59a1",
                SnapshotEncryptionKey = new CustomerEncryptionKey(),
                LicenseCodes          =
                {
                    -3549522739643304114L,
                },
                ChainName        = "chain_name66f3d828",
                LabelFingerprint = "label_fingerprint06ccff3a",
                Status           = "status5444cb9a",
                DiskSizeGb       = 7103353205508136450L,
                StorageLocations =
                {
                    "storage_locationse772402d",
                },
                Licenses =
                {
                    "licensesd1cc2f9d",
                },
                LocationHint       = "location_hint666f366c",
                Description        = "description2cf9da67",
                StorageBytes       = 8453704516828373557L,
                DownloadBytes      = -6512123273633363558L,
                SourceDisk         = "source_disk0eec086f",
                SourceDiskId       = "source_disk_id020f9fb8",
                SelfLink           = "self_link7e87f12d",
                AutoCreated        = true,
                SatisfiesPzs       = false,
                StorageBytesStatus = "storage_bytes_statusfdb1e9b2",
                Labels             =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                SourceDiskEncryptionKey = new CustomerEncryptionKey(),
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SnapshotsClient client   = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            Snapshot        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #6
0
        public async stt::Task SetLabelsAsync()
        {
            moq::Mock <Snapshots.SnapshotsClient> mockGrpcClient = new moq::Mock <Snapshots.SnapshotsClient>(moq::MockBehavior.Strict);
            SetLabelsSnapshotRequest request = new SetLabelsSnapshotRequest
            {
                Resource = "resource164eab96",
                Project  = "projectaa6ff846",
                GlobalSetLabelsRequestResource = new GlobalSetLabelsRequest(),
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Operation responseCancellationToken = await client.SetLabelsAsync(request.Project, request.Resource, request.GlobalSetLabelsRequestResource, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #7
0
        public void DeleteRequestObject()
        {
            moq::Mock <Snapshots.SnapshotsClient> mockGrpcClient = new moq::Mock <Snapshots.SnapshotsClient>(moq::MockBehavior.Strict);
            DeleteSnapshotRequest request = new DeleteSnapshotRequest
            {
                RequestId = "request_id362c8df6",
                Project   = "projectaa6ff846",
                Snapshot  = "snapshotded322c3",
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

            mockGrpcClient.Setup(x => x.Delete(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SnapshotsClient client   = new SnapshotsClientImpl(mockGrpcClient.Object, null);
            Operation       response = client.Delete(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #8
0
        public async stt::Task GetAsync()
        {
            moq::Mock <Snapshots.SnapshotsClient> mockGrpcClient = new moq::Mock <Snapshots.SnapshotsClient>(moq::MockBehavior.Strict);
            GetSnapshotRequest request = new GetSnapshotRequest
            {
                Project  = "projectaa6ff846",
                Snapshot = "snapshotded322c3",
            };
            Snapshot expectedResponse = new Snapshot
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp     = "creation_timestamp235e59a1",
                SnapshotEncryptionKey = new CustomerEncryptionKey(),
                LicenseCodes          =
                {
                    -3549522739643304114L,
                },
                ChainName        = "chain_name66f3d828",
                LabelFingerprint = "label_fingerprint06ccff3a",
                Status           = Snapshot.Types.Status.Deleting,
                DiskSizeGb       = 7103353205508136450L,
                StorageLocations =
                {
                    "storage_locationse772402d",
                },
                Licenses =
                {
                    "licensesd1cc2f9d",
                },
                LocationHint       = "location_hint666f366c",
                Description        = "description2cf9da67",
                StorageBytes       = 8453704516828373557L,
                DownloadBytes      = -6512123273633363558L,
                SourceDisk         = "source_disk0eec086f",
                SourceDiskId       = "source_disk_id020f9fb8",
                SelfLink           = "self_link7e87f12d",
                AutoCreated        = true,
                SatisfiesPzs       = false,
                StorageBytesStatus = Snapshot.Types.StorageBytesStatus.UndefinedStorageBytesStatus,
                Labels             =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                SourceDiskEncryptionKey = new CustomerEncryptionKey(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Snapshot responseCancellationToken = await client.GetAsync(request.Project, request.Snapshot, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }