public async stt::Task TestIamPermissionsAsync() { moq::Mock <RegionDisks.RegionDisksClient> mockGrpcClient = new moq::Mock <RegionDisks.RegionDisksClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); TestIamPermissionsRegionDiskRequest request = new TestIamPermissionsRegionDiskRequest { Region = "regionedb20d96", 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)); RegionDisksClient client = new RegionDisksClientImpl(mockGrpcClient.Object, null); TestPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TestPermissionsResponse responseCancellationToken = await client.TestIamPermissionsAsync(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void TestIamPermissions() { moq::Mock <RegionDisks.RegionDisksClient> mockGrpcClient = new moq::Mock <RegionDisks.RegionDisksClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); TestIamPermissionsRegionDiskRequest request = new TestIamPermissionsRegionDiskRequest { Region = "regionedb20d96", 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); RegionDisksClient client = new RegionDisksClientImpl(mockGrpcClient.Object, null); TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Region, request.Resource, request.TestPermissionsRequestResource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void SetIamPolicy() { moq::Mock <RegionDisks.RegionDisksClient> mockGrpcClient = new moq::Mock <RegionDisks.RegionDisksClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); SetIamPolicyRegionDiskRequest request = new SetIamPolicyRegionDiskRequest { Region = "regionedb20d96", Resource = "resource164eab96", Project = "projectaa6ff846", RegionSetPolicyRequestResource = new RegionSetPolicyRequest(), }; 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); RegionDisksClient client = new RegionDisksClientImpl(mockGrpcClient.Object, null); Policy response = client.SetIamPolicy(request.Project, request.Region, request.Resource, request.RegionSetPolicyRequestResource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task SetIamPolicyAsync() { moq::Mock <RegionDisks.RegionDisksClient> mockGrpcClient = new moq::Mock <RegionDisks.RegionDisksClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); SetIamPolicyRegionDiskRequest request = new SetIamPolicyRegionDiskRequest { Region = "regionedb20d96", Resource = "resource164eab96", Project = "projectaa6ff846", RegionSetPolicyRequestResource = new RegionSetPolicyRequest(), }; 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)); RegionDisksClient client = new RegionDisksClientImpl(mockGrpcClient.Object, null); Policy responseCallSettings = await client.SetIamPolicyAsync(request.Project, request.Region, request.Resource, request.RegionSetPolicyRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Policy responseCancellationToken = await client.SetIamPolicyAsync(request.Project, request.Region, request.Resource, request.RegionSetPolicyRequestResource, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetRequestObject() { moq::Mock <RegionDisks.RegionDisksClient> mockGrpcClient = new moq::Mock <RegionDisks.RegionDisksClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetRegionDiskRequest request = new GetRegionDiskRequest { Disk = "disk028b6875", Region = "regionedb20d96", Project = "projectaa6ff846", }; Disk expectedResponse = new Disk { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", Type = "typee2cc9d59", Zone = "zone255f4ea8", ResourcePolicies = { "resource_policiesdff15734", }, CreationTimestamp = "creation_timestamp235e59a1", LastAttachTimestamp = "last_attach_timestamp4fe3fe94", LicenseCodes = { -3549522739643304114L, }, ReplicaZones = { "replica_zonesc1977354", }, SourceImage = "source_image5e9c0c38", SourceImageId = "source_image_id954b5e55", LastDetachTimestamp = "last_detach_timestampffef196b", GuestOsFeatures = { new GuestOsFeature(), }, SourceSnapshotId = "source_snapshot_id008ab5dd", Users = { "users2a5cc69b", }, SourceSnapshot = "source_snapshot1fcf3da1", Region = "regionedb20d96", LabelFingerprint = "label_fingerprint06ccff3a", Status = "status5444cb9a", ProvisionedIops = -3779563869670119518L, SourceStorageObject = "source_storage_object4e059972", DiskEncryptionKey = new CustomerEncryptionKey(), SourceSnapshotEncryptionKey = new CustomerEncryptionKey(), Licenses = { "licensesd1cc2f9d", }, LocationHint = "location_hint666f366c", Options = "optionsa965da93", SourceImageEncryptionKey = new CustomerEncryptionKey(), PhysicalBlockSizeBytes = -7292518380745299537L, Description = "description2cf9da67", SourceDisk = "source_disk0eec086f", SourceDiskId = "source_disk_id020f9fb8", SelfLink = "self_link7e87f12d", SatisfiesPzs = false, SizeGb = -3653169847519542788L, Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RegionDisksClient client = new RegionDisksClientImpl(mockGrpcClient.Object, null); Disk response = client.Get(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }