Beispiel #1
0
        public async stt::Task CreateEntityTypeResourceNamesAsync()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            CreateEntityTypeRequest request = new CreateEntityTypeRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                EntityType        = new EntityType(),
            };
            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.CreateEntityTypeAsync(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.CreateEntityTypeAsync(request.ParentAsAgentName, request.EntityType, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task CreateEntityTypeAsync3()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

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

            mockGrpcClient.Setup(x => x.CreateEntityTypeAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <EntityType>(Task.FromResult(expectedResponse), null, null, null, null));
            EntityTypesClient client   = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        response = await client.CreateEntityTypeAsync(request);

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