public async stt::Task UpdateKnowledgeBaseAsync() { moq::Mock <KnowledgeBases.KnowledgeBasesClient> mockGrpcClient = new moq::Mock <KnowledgeBases.KnowledgeBasesClient>(moq::MockBehavior.Strict); UpdateKnowledgeBaseRequest request = new UpdateKnowledgeBaseRequest { KnowledgeBase = new KnowledgeBase(), UpdateMask = new wkt::FieldMask(), }; KnowledgeBase expectedResponse = new KnowledgeBase { KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"), DisplayName = "display_name137f65c2", LanguageCode = "language_code2f6c7160", }; mockGrpcClient.Setup(x => x.UpdateKnowledgeBaseAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <KnowledgeBase>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KnowledgeBasesClient client = new KnowledgeBasesClientImpl(mockGrpcClient.Object, null); KnowledgeBase responseCallSettings = await client.UpdateKnowledgeBaseAsync(request.KnowledgeBase, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); KnowledgeBase responseCancellationToken = await client.UpdateKnowledgeBaseAsync(request.KnowledgeBase, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void DeleteKnowledgeBaseResourceNames() { moq::Mock <KnowledgeBases.KnowledgeBasesClient> mockGrpcClient = new moq::Mock <KnowledgeBases.KnowledgeBasesClient>(moq::MockBehavior.Strict); DeleteKnowledgeBaseRequest request = new DeleteKnowledgeBaseRequest { KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteKnowledgeBase(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KnowledgeBasesClient client = new KnowledgeBasesClientImpl(mockGrpcClient.Object, null); client.DeleteKnowledgeBase(request.KnowledgeBaseName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteKnowledgeBaseResourceNamesAsync() { moq::Mock <KnowledgeBases.KnowledgeBasesClient> mockGrpcClient = new moq::Mock <KnowledgeBases.KnowledgeBasesClient>(moq::MockBehavior.Strict); DeleteKnowledgeBaseRequest request = new DeleteKnowledgeBaseRequest { KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteKnowledgeBaseAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KnowledgeBasesClient client = new KnowledgeBasesClientImpl(mockGrpcClient.Object, null); await client.DeleteKnowledgeBaseAsync(request.KnowledgeBaseName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteKnowledgeBaseAsync(request.KnowledgeBaseName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public void GetKnowledgeBase() { moq::Mock <KnowledgeBases.KnowledgeBasesClient> mockGrpcClient = new moq::Mock <KnowledgeBases.KnowledgeBasesClient>(moq::MockBehavior.Strict); GetKnowledgeBaseRequest request = new GetKnowledgeBaseRequest { KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"), }; KnowledgeBase expectedResponse = new KnowledgeBase { KnowledgeBaseName = KnowledgeBaseName.FromProjectKnowledgeBase("[PROJECT]", "[KNOWLEDGE_BASE]"), DisplayName = "display_name137f65c2", LanguageCode = "language_code2f6c7160", }; mockGrpcClient.Setup(x => x.GetKnowledgeBase(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KnowledgeBasesClient client = new KnowledgeBasesClientImpl(mockGrpcClient.Object, null); KnowledgeBase response = client.GetKnowledgeBase(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }