@@ -42,8 +42,10 @@ public void FormRecognizerClientCannotAuthenticateWithFakeApiKey()
4242 }
4343 }
4444
45+ #region StartRecognizeContent
46+
4547 [ Test ]
46- public async Task FormRecognizerClientCanAuthenticateWithTokenCredential ( )
48+ public async Task StartRecognizeContentCanAuthenticateWithTokenCredential ( )
4749 {
4850 var client = CreateFormRecognizerClient ( useTokenCredential : true ) ;
4951 RecognizeContentOperation operation ;
@@ -63,8 +65,6 @@ public async Task FormRecognizerClientCanAuthenticateWithTokenCredential()
6365 Assert . AreEqual ( "Contoso" , formPage . Lines [ 0 ] . Text ) ;
6466 }
6567
66- #region StartRecognizeContent
67-
6868 /// <summary>
6969 /// Verifies that the <see cref="FormRecognizerClient" /> is able to connect to the Form
7070 /// Recognizer cognitive service and perform operations.
@@ -521,6 +521,32 @@ public void StartRecognizeContentWithNoSupporttedLanguage()
521521
522522 #region StartRecognizeReceipts
523523
524+ [ Test ]
525+ public async Task StartRecognizeReceiptsCanAuthenticateWithTokenCredential ( )
526+ {
527+ var client = CreateFormRecognizerClient ( useTokenCredential : true ) ;
528+ RecognizeReceiptsOperation operation ;
529+
530+ using var stream = FormRecognizerTestEnvironment . CreateStream ( TestFile . ReceiptJpg ) ;
531+ using ( Recording . DisableRequestBodyRecording ( ) )
532+ {
533+ operation = await client . StartRecognizeReceiptsAsync ( stream ) ;
534+ }
535+
536+ // Sanity check to make sure we got an actual response back from the service.
537+
538+ RecognizedFormCollection formPage = await operation . WaitForCompletionAsync ( PollingInterval ) ;
539+
540+ RecognizedForm form = formPage . Single ( ) ;
541+ Assert . NotNull ( form ) ;
542+
543+ ValidatePrebuiltForm (
544+ form ,
545+ includeFieldElements : true ,
546+ expectedFirstPageNumber : 1 ,
547+ expectedLastPageNumber : 1 ) ;
548+ }
549+
524550 /// <summary>
525551 /// Verifies that the <see cref="FormRecognizerClient" /> is able to connect to the Form
526552 /// Recognizer cognitive service and perform analysis of receipts.
@@ -969,6 +995,32 @@ public void StartRecognizeReceiptsWithWrongLocale()
969995
970996 #region StartRecognizeBusinessCards
971997
998+ [ Test ]
999+ public async Task StartRecognizeBusinessCardsCanAuthenticateWithTokenCredential ( )
1000+ {
1001+ var client = CreateFormRecognizerClient ( useTokenCredential : true ) ;
1002+ RecognizeBusinessCardsOperation operation ;
1003+
1004+ using var stream = FormRecognizerTestEnvironment . CreateStream ( TestFile . BusinessCardJpg ) ;
1005+ using ( Recording . DisableRequestBodyRecording ( ) )
1006+ {
1007+ operation = await client . StartRecognizeBusinessCardsAsync ( stream ) ;
1008+ }
1009+
1010+ // Sanity check to make sure we got an actual response back from the service.
1011+
1012+ RecognizedFormCollection formPage = await operation . WaitForCompletionAsync ( PollingInterval ) ;
1013+
1014+ RecognizedForm form = formPage . Single ( ) ;
1015+ Assert . NotNull ( form ) ;
1016+
1017+ ValidatePrebuiltForm (
1018+ form ,
1019+ includeFieldElements : true ,
1020+ expectedFirstPageNumber : 1 ,
1021+ expectedLastPageNumber : 1 ) ;
1022+ }
1023+
9721024 [ Test ]
9731025 [ TestCase ( true ) ]
9741026 [ TestCase ( false ) ]
@@ -1333,6 +1385,32 @@ public async Task StartRecognizeBusinessCardsCanParseMultipageForm(bool useStrea
13331385
13341386 #region StartRecognizeInvoices
13351387
1388+ [ Test ]
1389+ public async Task StartRecognizeInvoicesCanAuthenticateWithTokenCredential ( )
1390+ {
1391+ var client = CreateFormRecognizerClient ( useTokenCredential : true ) ;
1392+ RecognizeInvoicesOperation operation ;
1393+
1394+ using var stream = FormRecognizerTestEnvironment . CreateStream ( TestFile . InvoicePdf ) ;
1395+ using ( Recording . DisableRequestBodyRecording ( ) )
1396+ {
1397+ operation = await client . StartRecognizeInvoicesAsync ( stream ) ;
1398+ }
1399+
1400+ // Sanity check to make sure we got an actual response back from the service.
1401+
1402+ RecognizedFormCollection formPage = await operation . WaitForCompletionAsync ( PollingInterval ) ;
1403+
1404+ RecognizedForm form = formPage . Single ( ) ;
1405+ Assert . NotNull ( form ) ;
1406+
1407+ ValidatePrebuiltForm (
1408+ form ,
1409+ includeFieldElements : true ,
1410+ expectedFirstPageNumber : 1 ,
1411+ expectedLastPageNumber : 1 ) ;
1412+ }
1413+
13361414 [ Test ]
13371415 [ TestCase ( true ) ]
13381416 [ TestCase ( false ) ]
@@ -1671,6 +1749,49 @@ public void StartRecognizeInvoicesWithWrongLocale()
16711749
16721750 #region StartRecognizeCustomForms
16731751
1752+ [ Test ]
1753+ [ TestCase ( true ) ]
1754+ [ TestCase ( false ) ]
1755+ public async Task StartRecognizeCustomFormsCanAuthenticateWithTokenCredential ( bool useTrainingLabels )
1756+ {
1757+ var client = CreateFormRecognizerClient ( useTokenCredential : true ) ;
1758+ await using var trainedModel = await CreateDisposableTrainedModelAsync ( useTrainingLabels ) ;
1759+ RecognizeCustomFormsOperation operation ;
1760+
1761+ using var stream = FormRecognizerTestEnvironment . CreateStream ( TestFile . Form1 ) ;
1762+ using ( Recording . DisableRequestBodyRecording ( ) )
1763+ {
1764+ operation = await client . StartRecognizeCustomFormsAsync ( trainedModel . ModelId , stream ) ;
1765+ }
1766+
1767+ // Sanity check to make sure we got an actual response back from the service.
1768+
1769+ RecognizedFormCollection formPage = await operation . WaitForCompletionAsync ( PollingInterval ) ;
1770+
1771+ RecognizedForm form = formPage . Single ( ) ;
1772+ Assert . NotNull ( form ) ;
1773+
1774+ if ( useTrainingLabels )
1775+ {
1776+ ValidateModelWithLabelsForm (
1777+ form ,
1778+ trainedModel . ModelId ,
1779+ includeFieldElements : false ,
1780+ expectedFirstPageNumber : 1 ,
1781+ expectedLastPageNumber : 1 ,
1782+ isComposedModel : false ) ;
1783+ }
1784+ else
1785+ {
1786+ ValidateModelWithNoLabelsForm (
1787+ form ,
1788+ trainedModel . ModelId ,
1789+ includeFieldElements : false ,
1790+ expectedFirstPageNumber : 1 ,
1791+ expectedLastPageNumber : 1 ) ;
1792+ }
1793+ }
1794+
16741795 /// <summary>
16751796 /// Verifies that the <see cref="FormRecognizerClient" /> is able to connect to the Form
16761797 /// Recognizer cognitive service and perform analysis based on a custom labeled model.
0 commit comments