示例#1
0
        public async Task AnalyzeDocumentOperationCanPollFromNewObject()
        {
            var client = CreateDocumentAnalysisClient(out var nonInstrumentedClient);

            var uri       = DocumentAnalysisTestEnvironment.CreateUri(TestFile.ReceiptJpg);
            var operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-receipt", uri);

            Assert.IsNotNull(operation.GetRawResponse());

            var sameOperation = InstrumentOperation(new AnalyzeDocumentOperation(operation.Id, nonInstrumentedClient));
            await sameOperation.WaitForCompletionAsync();

            Assert.IsTrue(sameOperation.HasValue);
            Assert.AreEqual(1, sameOperation.Value.Pages.Count);
        }
示例#2
0
        public async Task StartAnalyzeDocumentSendsContentType()
        {
            var mockResponse = new MockResponse(202);

            mockResponse.AddHeader(new HttpHeader(Constants.OperationLocationHeader, OperationId));

            var mockTransport = new MockTransport(new[] { mockResponse, mockResponse });
            var options       = new DocumentAnalysisClientOptions()
            {
                Transport = mockTransport
            };
            var client = CreateInstrumentedClient(options);

            using var stream = DocumentAnalysisTestEnvironment.CreateStream(TestFile.InvoiceLeTiff);
            await client.StartAnalyzeDocumentAsync(FakeGuid, stream);

            var request = mockTransport.Requests.Single();

            Assert.True(request.Headers.TryGetValue("Content-Type", out var contentType));
            Assert.AreEqual("application/octet-stream", contentType);
        }
示例#3
0
        public async Task StartAnalyzeDocumentSendsUserSpecifiedLocale(string locale)
        {
            var mockResponse = new MockResponse(202);

            mockResponse.AddHeader(new HttpHeader(Constants.OperationLocationHeader, OperationId));

            var mockTransport = new MockTransport(new[] { mockResponse, mockResponse });
            var options       = new DocumentAnalysisClientOptions()
            {
                Transport = mockTransport
            };
            var client = CreateInstrumentedClient(options);

            using var stream = DocumentAnalysisTestEnvironment.CreateStream(TestFile.ReceiptJpg);
            var analyzeOptions = new AnalyzeDocumentOptions {
                Locale = locale
            };
            await client.StartAnalyzeDocumentAsync(FakeGuid, stream, analyzeOptions);

            var requestUriQuery   = mockTransport.Requests.Single().Uri.Query;
            var expectedSubstring = $"locale={locale}";

            Assert.True(requestUriQuery.Contains(expectedSubstring));
        }