Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Azure.AI.FormRecognizer
{
public enum FormContentType
{
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Json = 0,
Pdf = 1,
Png = 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ var client = new DocumentModelAdministrationClient(new Uri(endpoint), credential
In our case, we will be writing an application that collects the expenses a company is making. There are 4 main areas where we get purchase orders from (office supplies, office equipment, furniture, and cleaning supplies). Because each area has its own document with its own structure, we need to create a model per document type.

```C# Snippet:FormRecognizerSampleBuildVariousModels
// For this sample, you can use the training forms found in the `trainingFiles` folder.
// Upload the forms to your storage container and then generate a container SAS URL.
// For instructions on setting up forms for training in an Azure Storage Blob Container, see
// For this sample, you can use the training documents found in the `trainingFiles` folder.
// Upload the documents to your storage container and then generate a container SAS URL.
// For instructions on setting up documents for training in an Azure Storage Blob Container, see
// https://aka.ms/azsdk/formrecognizer/buildtrainingset

Uri officeSuppliesUri = new Uri("<purchaseOrderOfficeSuppliesUri>");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.ComponentModel;

namespace Azure.AI.FormRecognizer
{
/// <summary>
Expand All @@ -11,6 +13,7 @@ public enum FormContentType
/// <summary>
/// Used for JSON files.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
Json,

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public async Task AnalyzeDocumentWithCustomModel(bool useStream)
}

[RecordedTest]
public async Task AnalyzeDocumentWithCustomModelWithLabelsAndSelectionMarks()
public async Task AnalyzeDocumentWithCustomModelWithSelectionMarks()
{
var client = CreateDocumentAnalysisClient();
var modelId = Recording.GenerateId();
Expand Down Expand Up @@ -308,7 +308,7 @@ public async Task AnalyzeDocumentWithCustomModelWithLabelsAndSelectionMarks()
[RecordedTest]
[TestCase(true)]
[TestCase(false)]
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageForm(bool useStream)
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageDocument(bool useStream)
{
var client = CreateDocumentAnalysisClient();
var modelId = Recording.GenerateId();
Expand Down Expand Up @@ -364,7 +364,7 @@ public async Task AnalyzeDocumentWithCustomModelCanParseMultipageForm(bool useSt
[RecordedTest]
[TestCase(true)]
[TestCase(false)]
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageFormWithBlankPage(bool useStream)
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageDocumentWithBlankPage(bool useStream)
{
var client = CreateDocumentAnalysisClient();
var modelId = Recording.GenerateId();
Expand Down Expand Up @@ -413,7 +413,7 @@ public async Task AnalyzeDocumentWithCustomModelCanParseMultipageFormWithBlankPa
}

[RecordedTest]
public async Task AnalyzeDocumentWithCustomModelCanParseDifferentTypeOfForm()
public async Task AnalyzeDocumentWithCustomModelCanParseDifferentTypeOfDocument()
{
var client = CreateDocumentAnalysisClient();
var modelId = Recording.GenerateId();
Expand Down Expand Up @@ -545,7 +545,7 @@ public async Task AnalyzeDocumentPopulatesDocumentPageJpg(bool useStream)
DocumentPage page = result.Pages.Single();

// The expected values are based on the values returned by the service, and not the actual
// values present in the form. We are not testing the service here, but the SDK.
// values present in the document. We are not testing the service here, but the SDK.

Assert.AreEqual(DocumentPageLengthUnit.Pixel, page.Unit);
Assert.AreEqual(1700, page.Width);
Expand Down Expand Up @@ -1028,7 +1028,7 @@ public async Task AnalyzeDocumentPopulatesLayoutPagePdf(bool useStream)
DocumentPage page = result.Pages.Single();

// The expected values are based on the values returned by the service, and not the actual
// values present in the form. We are not testing the service here, but the SDK.
// values present in the document. We are not testing the service here, but the SDK.

Assert.AreEqual(DocumentPageLengthUnit.Inch, page.Unit);
Assert.AreEqual(8.5, page.Width);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ public async Task AnalyzeDocumentCanReadPageAndLanguage(bool useStream)
DocumentPage page = result.Pages.Single();

// The expected values are based on the values returned by the service, and not the actual
// values present in the form. We are not testing the service here, but the SDK.
// values present in the document. We are not testing the service here, but the SDK.

Assert.AreEqual(DocumentPageLengthUnit.Inch, page.Unit);
Assert.AreEqual(8.5, page.Width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async Task BuildDocumentClassifierWithAzureBlobFileListSource()
#region Get

[RecordedTest]
[TestCase(true, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/35243")]
[TestCase(true)]
[TestCase(false)]
public async Task GetDocumentClassifier(bool useTokenCredential)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeBusinessCards` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeBusinessCards` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]

public class RecognizeBusinessCardsLiveTests : FormRecognizerLiveTestBase
{
public RecognizeBusinessCardsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeContent` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeContent` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(
FormRecognizerClientOptions.ServiceVersion.V2_0,
FormRecognizerClientOptions.ServiceVersion.V2_1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeCustomForms` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeCustomForms` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(
FormRecognizerClientOptions.ServiceVersion.V2_0,
FormRecognizerClientOptions.ServiceVersion.V2_1)]
Expand Down Expand Up @@ -410,28 +410,18 @@ public async Task StartRecognizeCustomFormsWithoutLabels(bool useStream, bool in
}

[RecordedTest]
[TestCase(true)]
[TestCase(false, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/12319")]
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bool useStream)
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm()
{
var client = CreateFormRecognizerClient();
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
RecognizeCustomFormsOperation operation;

await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false, ContainerType.MultipageFiles);

if (useStream)
{
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}
}
else
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
using (Recording.DisableRequestBodyRecording())
{
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}

RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();
Expand Down Expand Up @@ -465,6 +455,22 @@ public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bo
Assert.AreEqual("Southridge Video", secondFormFieldInPage.ValueData.Text);
}

[RecordedTest]
public async Task StartRecognizeCustomFormsFromUriWithoutLabelsThrowsWithMultipageForm()
{
var client = CreateFormRecognizerClient();
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };

await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false, ContainerType.MultipageFiles);

var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
var operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);

var exception = Assert.ThrowsAsync<RequestFailedException>(async () => await operation.WaitForCompletionAsync());

Assert.AreEqual("2002", exception.ErrorCode);
}

[RecordedTest]
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
{
Expand Down Expand Up @@ -500,28 +506,18 @@ public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
}

[RecordedTest]
[TestCase(true)]
[TestCase(false, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/12319")]
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageFormWithBlankPage(bool useStream)
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageFormWithBlankPage()
{
var client = CreateFormRecognizerClient();
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
RecognizeCustomFormsOperation operation;

await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false);

if (useStream)
{
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}
}
else
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipageBlank);
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}

RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeIdentityDocuments` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeIdentityDocuments` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]
public class RecognizeIdentityDocumentsLiveTests : FormRecognizerLiveTestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeInvoices` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeInvoices` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]

public class RecognizeInvoicesLiveTests : FormRecognizerLiveTestBase
{
public RecognizeInvoicesLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

/// <summary>
/// The suite of tests for the `StartRecognizeReceipts` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
namespace Azure.AI.FormRecognizer.Tests
{
/// <summary>
/// The suite of tests for the `StartRecognizeReceipts` methods in the <see cref="FormRecognizerClient"/> class.
/// </summary>
/// <remarks>
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[ClientTestFixture(
FormRecognizerClientOptions.ServiceVersion.V2_0,
FormRecognizerClientOptions.ServiceVersion.V2_1)]
Expand Down
Loading