//[UnityTest, Order(20)]
        public IEnumerator TestAnalyzeDocument()
        {
            BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(
                bearerToken: "{BEARER_TOKEN}"
                );
            DiscoveryService cpdService = new DiscoveryService(versionDate, authenticator);

            cpdService.SetServiceUrl("{SERVICE_URL}");
            cpdService.WithHeader("X-Watson-Test", "1");

            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to AnalyzeDocument...");
            AnalyzedDocument analyzeDocumentResponse = null;

            using (FileStream fs = File.OpenRead(analyzeDocumentFile))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    fs.CopyTo(ms);

                    cpdService.AnalyzeDocument(
                        callback: (DetailedResponse <AnalyzedDocument> response, IBMError error) =>
                    {
                        Log.Debug("DiscoveryServiceV2IntegrationTests", "AnalyzeDocument result: {0}", response.Response);
                        analyzeDocumentResponse = response.Result;
                        Assert.IsNull(error);
                        Assert.IsNotNull(analyzeDocumentResponse);
                    },
                        projectId: "{projectId}",
                        collectionId: "{collectionId}",
                        file: ms,
                        filename: "exampleConfigurationData.json",
                        fileContentType: "application/json"
                        );
                }
            }

            while (analyzeDocumentResponse == null)
            {
                yield return(null);
            }
        }
コード例 #2
0
 public void TestAnalyzeDocument()
 {
     using (FileStream fs = File.OpenRead(filepathAnalyzeDoc))
     {
         using (MemoryStream ms = new MemoryStream())
         {
             fs.CopyTo(ms);
             service.WithHeader("X-Watson-Test", "1");
             var response = service.AnalyzeDocument(
                 projectId: projectId,
                 collectionId: collectionId,
                 file: ms,
                 filename: "problem.json",
                 fileContentType: DiscoveryService.AnalyzeDocumentEnums.FileContentTypeValue.APPLICATION_JSON,
                 metadata: "{ \"metadata\": \"value\" }"
                 );
             Assert.IsNotNull(response);
             Assert.IsNotNull(response.Result);
         }
     }
 }