Пример #1
0
        public void GetEntityType()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            GetEntityTypeRequest request = new GetEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName    = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                DisplayName       = "display_name137f65c2",
                Kind              = EntityType.Types.Kind.Regexp,
                AutoExpansionMode = EntityType.Types.AutoExpansionMode.Default,
                Entities          =
                {
                    new EntityType.Types.Entity(),
                },
                ExcludedPhrases =
                {
                    new EntityType.Types.ExcludedPhrase(),
                },
                EnableFuzzyExtraction = false,
                Redact = true,
            };

            mockGrpcClient.Setup(x => x.GetEntityType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EntityTypesClient client   = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        response = client.GetEntityType(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for GetEntityType</summary>
 public void GetEntityTypeResourceNames()
 {
     // Snippet: GetEntityType(EntityTypeName, CallSettings)
     // Create client
     EntityTypesClient entityTypesClient = EntityTypesClient.Create();
     // Initialize request argument(s)
     EntityTypeName name = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]");
     // Make the request
     EntityType response = entityTypesClient.GetEntityType(name);
     // End snippet
 }
        /// <summary>Snippet for DeleteEntityTypeAsync</summary>
        public async Task DeleteEntityTypeResourceNamesAsync()
        {
            // Snippet: DeleteEntityTypeAsync(EntityTypeName, CallSettings)
            // Additional: DeleteEntityTypeAsync(EntityTypeName, CancellationToken)
            // Create client
            EntityTypesClient entityTypesClient = await EntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            EntityTypeName name = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]");
            // Make the request
            await entityTypesClient.DeleteEntityTypeAsync(name);

            // End snippet
        }
 /// <summary>Snippet for GetEntityType</summary>
 public void GetEntityTypeRequestObject()
 {
     // Snippet: GetEntityType(GetEntityTypeRequest, CallSettings)
     // Create client
     EntityTypesClient entityTypesClient = EntityTypesClient.Create();
     // Initialize request argument(s)
     GetEntityTypeRequest request = new GetEntityTypeRequest
     {
         EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
         LanguageCode   = "",
     };
     // Make the request
     EntityType response = entityTypesClient.GetEntityType(request);
     // End snippet
 }
        /// <summary>Snippet for DeleteEntityType</summary>
        public void DeleteEntityTypeRequestObject()
        {
            // Snippet: DeleteEntityType(DeleteEntityTypeRequest, CallSettings)
            // Create client
            EntityTypesClient entityTypesClient = EntityTypesClient.Create();
            // Initialize request argument(s)
            DeleteEntityTypeRequest request = new DeleteEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                Force          = false,
            };

            // Make the request
            entityTypesClient.DeleteEntityType(request);
            // End snippet
        }
Пример #6
0
        public void DeleteEntityTypeResourceNames()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            DeleteEntityTypeRequest request = new DeleteEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteEntityType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EntityTypesClient client = new EntityTypesClientImpl(mockGrpcClient.Object, null);

            client.DeleteEntityType(request.EntityTypeName);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for DeleteEntityTypeAsync</summary>
        public async Task DeleteEntityTypeRequestObjectAsync()
        {
            // Snippet: DeleteEntityTypeAsync(DeleteEntityTypeRequest, CallSettings)
            // Additional: DeleteEntityTypeAsync(DeleteEntityTypeRequest, CancellationToken)
            // Create client
            EntityTypesClient entityTypesClient = await EntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            DeleteEntityTypeRequest request = new DeleteEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                Force          = false,
            };
            // Make the request
            await entityTypesClient.DeleteEntityTypeAsync(request);

            // End snippet
        }
        /// <summary>Snippet for GetEntityTypeAsync</summary>
        public async Task GetEntityTypeRequestObjectAsync()
        {
            // Snippet: GetEntityTypeAsync(GetEntityTypeRequest, CallSettings)
            // Additional: GetEntityTypeAsync(GetEntityTypeRequest, CancellationToken)
            // Create client
            EntityTypesClient entityTypesClient = await EntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            GetEntityTypeRequest request = new GetEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                LanguageCode   = "",
            };
            // Make the request
            EntityType response = await entityTypesClient.GetEntityTypeAsync(request);

            // End snippet
        }
Пример #9
0
        public async stt::Task DeleteEntityTypeResourceNamesAsync()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            DeleteEntityTypeRequest request = new DeleteEntityTypeRequest
            {
                EntityTypeName = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteEntityTypeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            EntityTypesClient client = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            await client.DeleteEntityTypeAsync(request.EntityTypeName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteEntityTypeAsync(request.EntityTypeName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
Пример #10
0
        public async stt::Task UpdateEntityTypeRequestObjectAsync()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            UpdateEntityTypeRequest request = new UpdateEntityTypeRequest
            {
                EntityType   = new EntityType(),
                LanguageCode = "language_code2f6c7160",
                UpdateMask   = new wkt::FieldMask(),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName    = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                DisplayName       = "display_name137f65c2",
                Kind              = EntityType.Types.Kind.Regexp,
                AutoExpansionMode = EntityType.Types.AutoExpansionMode.Default,
                Entities          =
                {
                    new EntityType.Types.Entity(),
                },
                ExcludedPhrases =
                {
                    new EntityType.Types.ExcludedPhrase(),
                },
                EnableFuzzyExtraction = false,
                Redact = true,
            };

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

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

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