예제 #1
0
        public void GetTagKey()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTagKeyRequest request = new GetTagKeyRequest
            {
                TagKeyName = TagKeyName.FromTagKey("[TAG_KEY]"),
            };
            TagKey expectedResponse = new TagKey
            {
                TagKeyName     = TagKeyName.FromTagKey("[TAG_KEY]"),
                Parent         = "parent7858e4d0",
                ShortName      = "short_namec7ba9846",
                NamespacedName = "namespaced_namea4453147",
                Description    = "description2cf9da67",
                CreateTime     = new wkt::Timestamp(),
                UpdateTime     = new wkt::Timestamp(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetTagKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TagKeysClient client   = new TagKeysClientImpl(mockGrpcClient.Object, null);
            TagKey        response = client.GetTagKey(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task TestIamPermissionsResourceNamesAsync()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            gciv::TestIamPermissionsRequest request = new gciv::TestIamPermissionsRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Permissions            =
                {
                    "permissions535a2741",
                },
            };
            gciv::TestIamPermissionsResponse expectedResponse = new gciv::TestIamPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gciv::TestIamPermissionsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            TagKeysClient client = new TagKeysClientImpl(mockGrpcClient.Object, null);
            gciv::TestIamPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.ResourceAsResourceName, request.Permissions, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gciv::TestIamPermissionsResponse responseCancellationToken = await client.TestIamPermissionsAsync(request.ResourceAsResourceName, request.Permissions, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
        public void TestIamPermissionsResourceNames()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            gciv::TestIamPermissionsRequest request = new gciv::TestIamPermissionsRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Permissions            =
                {
                    "permissions535a2741",
                },
            };
            gciv::TestIamPermissionsResponse expectedResponse = new gciv::TestIamPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TagKeysClient client = new TagKeysClientImpl(mockGrpcClient.Object, null);
            gciv::TestIamPermissionsResponse response = client.TestIamPermissions(request.ResourceAsResourceName, request.Permissions);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #4
0
        public async stt::Task GetTagKeyRequestObjectAsync()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTagKeyRequest request = new GetTagKeyRequest
            {
                TagKeyName = TagKeyName.FromTagKey("[TAG_KEY]"),
            };
            TagKey expectedResponse = new TagKey
            {
                TagKeyName     = TagKeyName.FromTagKey("[TAG_KEY]"),
                Parent         = "parent7858e4d0",
                ShortName      = "short_namec7ba9846",
                NamespacedName = "namespaced_namea4453147",
                Description    = "description2cf9da67",
                CreateTime     = new wkt::Timestamp(),
                UpdateTime     = new wkt::Timestamp(),
                Etag           = "etage8ad7218",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TagKey responseCancellationToken = await client.GetTagKeyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #5
0
        public async stt::Task SetIamPolicyResourceNamesAsync()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            gciv::SetIamPolicyRequest request = new gciv::SetIamPolicyRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Policy = new gciv::Policy(),
            };
            gciv::Policy expectedResponse = new gciv::Policy
            {
                Version  = 271578922,
                Etag     = proto::ByteString.CopyFromUtf8("etage8ad7218"),
                Bindings =
                {
                    new gciv::Binding(),
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #6
0
        public void SetIamPolicyResourceNames()
        {
            moq::Mock <TagKeys.TagKeysClient> mockGrpcClient = new moq::Mock <TagKeys.TagKeysClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            gciv::SetIamPolicyRequest request = new gciv::SetIamPolicyRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Policy = new gciv::Policy(),
            };
            gciv::Policy expectedResponse = new gciv::Policy
            {
                Version  = 271578922,
                Etag     = proto::ByteString.CopyFromUtf8("etage8ad7218"),
                Bindings =
                {
                    new gciv::Binding(),
                },
            };

            mockGrpcClient.Setup(x => x.SetIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TagKeysClient client   = new TagKeysClientImpl(mockGrpcClient.Object, null);
            gciv::Policy  response = client.SetIamPolicy(request.ResourceAsResourceName, request.Policy);

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