Beispiel #1
0
        public async stt::Task UpdateContextRequestObjectAsync()
        {
            moq::Mock <Contexts.ContextsClient> mockGrpcClient = new moq::Mock <Contexts.ContextsClient>(moq::MockBehavior.Strict);
            UpdateContextRequest request = new UpdateContextRequest
            {
                Context    = new Context(),
                UpdateMask = new wkt::FieldMask(),
            };
            Context expectedResponse = new Context
            {
                ContextName   = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = -2034952532,
                Parameters    = new wkt::Struct(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
 /// <summary>Snippet for GetContext</summary>
 public void GetContextResourceNames()
 {
     // Snippet: GetContext(ContextName, CallSettings)
     // Create client
     ContextsClient contextsClient = ContextsClient.Create();
     // Initialize request argument(s)
     ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
     // Make the request
     Context response = contextsClient.GetContext(name);
     // End snippet
 }
Beispiel #3
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityTypeResourceNames()
        {
            // Snippet: DeleteSessionEntityType(ContextName, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(name);
            // End snippet
        }
Beispiel #4
0
        /// <summary>Snippet for DeleteContextAsync</summary>
        public async Task DeleteContextResourceNamesAsync()
        {
            // Snippet: DeleteContextAsync(ContextName, CallSettings)
            // Additional: DeleteContextAsync(ContextName, CancellationToken)
            // Create client
            ContextsClient contextsClient = await ContextsClient.CreateAsync();

            // Initialize request argument(s)
            ContextName name = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]");
            // Make the request
            await contextsClient.DeleteContextAsync(name);

            // End snippet
        }
Beispiel #5
0
 /// <summary>Snippet for GetContext</summary>
 public void GetContextRequestObject()
 {
     // Snippet: GetContext(GetContextRequest, CallSettings)
     // Create client
     ContextsClient contextsClient = ContextsClient.Create();
     // Initialize request argument(s)
     GetContextRequest request = new GetContextRequest
     {
         ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
     };
     // Make the request
     Context response = contextsClient.GetContext(request);
     // End snippet
 }
        // [START dialogflow_delete_context]
        public static int Delete(string projectId, string sessionId, string contextId)
        {
            var client = ContextsClient.Create();

            var deletedContextRequest = new DeleteContextRequest
            {
                ContextName = ContextName.FromProjectSessionContext(projectId, sessionId, contextId)
            };

            client.DeleteContext(deletedContextRequest);

            Console.WriteLine($"Deleted Context: {contextId}");

            return(0);
        }
Beispiel #7
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityTypeRequestObject()
        {
            // Snippet: DeleteSessionEntityType(DeleteSessionEntityTypeRequest, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(request);
            // End snippet
        }
Beispiel #8
0
        public void DeleteSessionEntityTypeResourceNames()
        {
            moq::Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new moq::Mock <SessionEntityTypes.SessionEntityTypesClient>(moq::MockBehavior.Strict);
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

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

            client.DeleteSessionEntityType(request.ContextName);
            mockGrpcClient.VerifyAll();
        }
Beispiel #9
0
        /// <summary>Snippet for GetContextAsync</summary>
        public async Task GetContextRequestObjectAsync()
        {
            // Snippet: GetContextAsync(GetContextRequest, CallSettings)
            // Additional: GetContextAsync(GetContextRequest, CancellationToken)
            // Create client
            ContextsClient contextsClient = await ContextsClient.CreateAsync();

            // Initialize request argument(s)
            GetContextRequest request = new GetContextRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            // Make the request
            Context response = await contextsClient.GetContextAsync(request);

            // End snippet
        }
Beispiel #10
0
        /// <summary>Snippet for DeleteSessionEntityTypeAsync</summary>
        public async Task DeleteSessionEntityTypeRequestObjectAsync()
        {
            // Snippet: DeleteSessionEntityTypeAsync(DeleteSessionEntityTypeRequest, CallSettings)
            // Additional: DeleteSessionEntityTypeAsync(DeleteSessionEntityTypeRequest, CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            // Make the request
            await sessionEntityTypesClient.DeleteSessionEntityTypeAsync(request);

            // End snippet
        }
Beispiel #11
0
        public async stt::Task DeleteSessionEntityTypeResourceNamesAsync()
        {
            moq::Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new moq::Mock <SessionEntityTypes.SessionEntityTypesClient>(moq::MockBehavior.Strict);
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

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

            await client.DeleteSessionEntityTypeAsync(request.ContextName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
Beispiel #12
0
        public void GetContextRequestObject()
        {
            moq::Mock <Contexts.ContextsClient> mockGrpcClient = new moq::Mock <Contexts.ContextsClient>(moq::MockBehavior.Strict);
            GetContextRequest request = new GetContextRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };
            Context expectedResponse = new Context
            {
                ContextName   = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
                LifespanCount = -2034952532,
                Parameters    = new wkt::Struct(),
            };

            mockGrpcClient.Setup(x => x.GetContext(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ContextsClient client   = new ContextsClientImpl(mockGrpcClient.Object, null);
            Context        response = client.GetContext(request);

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