public async Task GetEntityTypeAsync()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetEntityTypeRequest expectedRequest = new GetEntityTypeRequest
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                DisplayName    = "displayName1615086568",
            };

            mockGrpcClient.Setup(x => x.GetEntityTypeAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <EntityType>(Task.FromResult(expectedResponse), null, null, null, null));
            EntityTypesClient client   = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityTypeName    name     = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]");
            EntityType        response = await client.GetEntityTypeAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetEntityType2()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetEntityTypeRequest expectedRequest = new GetEntityTypeRequest
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                LanguageCode   = "languageCode-412800396",
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                DisplayName    = "displayName1615086568",
            };

            mockGrpcClient.Setup(x => x.GetEntityType(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            EntityTypesClient client       = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityTypeName    name         = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]");
            string            languageCode = "languageCode-412800396";
            EntityType        response     = client.GetEntityType(name, languageCode);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetEntityType3()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetEntityTypeRequest request = new GetEntityTypeRequest
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName        = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                DisplayName           = "displayName1615086568",
                EnableFuzzyExtraction = true,
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #4
0
        public async stt::Task GetEntityTypeRequestObjectAsync()
        {
            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]"),
                LanguageCode   = "language_code2f6c7160",
            };
            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,
            };

            mockGrpcClient.Setup(x => x.GetEntityTypeAsync(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.GetEntityTypeAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #5
0
        public void GetEntityTypeRequestObject()
        {
            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]"),
                LanguageCode   = "language_code2f6c7160",
            };
            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,
            };

            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);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <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 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
        }