diff --git a/src/Mindee/Parsing/V2/ErrorItem.cs b/src/Mindee/Parsing/V2/ErrorItem.cs
new file mode 100644
index 00000000..8c524a61
--- /dev/null
+++ b/src/Mindee/Parsing/V2/ErrorItem.cs
@@ -0,0 +1,22 @@
+using System.Text.Json.Serialization;
+
+namespace Mindee.Parsing.V2
+{
+ ///
+ /// Explicit details on a problem.
+ ///
+ public class ErrorItem
+ {
+ ///
+ /// A JSON Pointer to the location of the body property.
+ ///
+ [JsonPropertyName("pointer")]
+ public string Pointer { get; set; }
+
+ ///
+ /// Explicit information on the issue.
+ ///
+ [JsonPropertyName("detail")]
+ public string Detail { get; set; }
+ }
+}
diff --git a/src/Mindee/Parsing/V2/ErrorResponse.cs b/src/Mindee/Parsing/V2/ErrorResponse.cs
index 6a40031b..aae82b38 100644
--- a/src/Mindee/Parsing/V2/ErrorResponse.cs
+++ b/src/Mindee/Parsing/V2/ErrorResponse.cs
@@ -1,23 +1,42 @@
+using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Mindee.Parsing.V2
{
///
- /// Represent an error information from the API response.
+ /// Error response detailing a problem. The format adheres to RFC 9457.
///
public class ErrorResponse
{
///
- /// Detail relevant to the error.
+ /// The HTTP status code returned by the server.
+ ///
+ [JsonPropertyName("status")]
+ public int Status { get; set; }
+
+ ///
+ /// A human-readable explanation specific to the occurrence of the problem.
///
[JsonPropertyName("detail")]
public string Detail { get; set; }
///
- /// Http error code.
+ /// A short, human-readable summary of the problem.
///
- [JsonPropertyName("status")]
- public int Status { get; set; }
+ [JsonPropertyName("title")]
+ public string Title { get; set; }
+
+ ///
+ /// A machine-readable code specific to the occurrence of the problem.
+ ///
+ [JsonPropertyName("code")]
+ public string Code { get; set; }
+
+ ///
+ /// A list of explicit details on the problem.
+ ///
+ [JsonPropertyName("errors")]
+ public List Errors { get; set; }
///
/// To make the error prettier to display.
diff --git a/src/Mindee/Parsing/V2/InferenceResult.cs b/src/Mindee/Parsing/V2/InferenceResult.cs
index 5dbd9678..caa0bc98 100644
--- a/src/Mindee/Parsing/V2/InferenceResult.cs
+++ b/src/Mindee/Parsing/V2/InferenceResult.cs
@@ -25,7 +25,7 @@ public class InferenceResult
/// RAG metadata.
///
[JsonPropertyName("rag")]
- public RawText Rag { get; set; }
+ public RagMetadata Rag { get; set; }
///
/// A prettier representation of the feature values.
diff --git a/src/Mindee/Parsing/V2/Job.cs b/src/Mindee/Parsing/V2/Job.cs
index 1581f0fc..1d49f1a1 100644
--- a/src/Mindee/Parsing/V2/Job.cs
+++ b/src/Mindee/Parsing/V2/Job.cs
@@ -5,19 +5,19 @@
namespace Mindee.Parsing.V2
{
///
- /// Defines an enqueued job.
+ /// Information on the processing of a file sent to the Mindee API.
///
public class Job
{
///
- /// Date and time the job was created at.
+ /// Date and time of the Job creation.
///
[JsonPropertyName("created_at")]
[JsonConverter(typeof(DateTimeJsonConverter))]
public DateTime CreatedAt { get; set; }
///
- /// Unique identifier of the job.
+ /// UUID of the Job.
///
[JsonPropertyName("id")]
public string Id { get; set; }
@@ -29,43 +29,43 @@ public class Job
public string Status { get; set; }
///
- /// An error encountered while processing the job.
+ /// If an error occurred during processing, contains the problem details.
///
[JsonPropertyName("error")]
public ErrorResponse Error { get; set; }
///
- /// ID of the model.
+ /// UUID of the model to be used for the inference.
///
[JsonPropertyName("model_id")]
public string ModelId { get; set; }
///
- /// Name of the file.
+ /// Name of the file sent.
///
[JsonPropertyName("file_name")]
public string FileName { get; set; }
///
- /// Optional Alias for the file.
+ /// Optional alias sent for the file.
///
[JsonPropertyName("file_alias")]
public string FileAlias { get; set; }
///
- /// URL to use for polling.
+ /// URL to poll for the Job status.
///
[JsonPropertyName("polling_url")]
public string PollingUrl { get; set; }
///
- /// URL to follow for the final result.
+ /// URL to retrieve the inference results. Will be filled once the inference is ready.
///
[JsonPropertyName("result_url")]
public string ResultUrl { get; set; }
///
- /// Webhooks to call.
+ /// List of responses from webhooks called. Empty until processing is finished.
///
[JsonPropertyName("webhooks")]
public List Webhooks { get; set; }
diff --git a/tests/Mindee.IntegrationTests/Constants.cs b/tests/Mindee.IntegrationTests/Constants.cs
new file mode 100644
index 00000000..b48af164
--- /dev/null
+++ b/tests/Mindee.IntegrationTests/Constants.cs
@@ -0,0 +1,12 @@
+namespace Mindee.IntegrationTests
+{
+ public static class Constants
+ {
+ public const string RootDir = "Resources/";
+
+ public const string V1RootDir = RootDir + "v1/";
+ public const string V1ProductDir = V1RootDir + "products/";
+
+ public const string V2RootDir = RootDir + "v2/";
+ }
+}
diff --git a/tests/Mindee.IntegrationTests/DependencyInjectionTest.cs b/tests/Mindee.IntegrationTests/DependencyInjectionTest.cs
index b9f41cd2..9ab3ce62 100644
--- a/tests/Mindee.IntegrationTests/DependencyInjectionTest.cs
+++ b/tests/Mindee.IntegrationTests/DependencyInjectionTest.cs
@@ -50,32 +50,32 @@ public void ShouldInitBothClients()
public async Task ShouldMaintainAuthenticationAcrossMultipleRequests()
{
MindeeClient instance1ClientV1 = _services.GetRequiredService();
- var inputSource1 = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource1 = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response1 = await instance1ClientV1.ParseAsync(inputSource1);
Assert.NotNull(response1);
Assert.True(response1.Document != null, "First V1 request should return a valid document");
MindeeClient instance2ClientV1 = _services.GetRequiredService();
- var inputSource2 = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource2 = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response2 = await instance2ClientV1.ParseAsync(inputSource2);
Assert.NotNull(response2);
Assert.True(response2.Document != null, "Second V1 request should return a valid document");
MindeeClientV2 instance1ClientV2 = _services.GetRequiredService();
- var inputSource3 = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource3 = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response3 = await instance1ClientV2.EnqueueInferenceAsync(
inputSource3,
new InferenceParameters(modelId: Environment.GetEnvironmentVariable("MindeeV2__Findoc__Model__Id")));
Assert.NotNull(response3);
Assert.True(response3.Job != null, "First V2 request should return a valid job");
- var inputSource4 = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource4 = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response4 = await instance1ClientV1.ParseAsync(inputSource4);
Assert.NotNull(response4);
Assert.True(response4.Document != null, "Third V3 request should return a valid document");
MindeeClientV2 instance2ClientV2 = _services.GetRequiredService();
- var inputSource5 = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource5 = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response5 = await instance2ClientV2.EnqueueInferenceAsync(
inputSource5,
new InferenceParameters(modelId: Environment.GetEnvironmentVariable("MindeeV2__Findoc__Model__Id")));
diff --git a/tests/Mindee.IntegrationTests/V1/Extraction/InvoiceSplitterAutoExtractionTest.cs b/tests/Mindee.IntegrationTests/V1/Extraction/InvoiceSplitterAutoExtractionTest.cs
index b2e38e7a..21b08da3 100644
--- a/tests/Mindee.IntegrationTests/V1/Extraction/InvoiceSplitterAutoExtractionTest.cs
+++ b/tests/Mindee.IntegrationTests/V1/Extraction/InvoiceSplitterAutoExtractionTest.cs
@@ -26,7 +26,7 @@ public async Task GivenAPdf_ShouldExtractInvoicesStrict_MustSucceed()
{
var apiKey = Environment.GetEnvironmentVariable("Mindee__ApiKey");
var client = TestingUtilities.GetOrGenerateMindeeClient(apiKey);
- var invoiceSplitterBytes = File.ReadAllBytes("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var invoiceSplitterBytes = File.ReadAllBytes(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var invoiceSplitterInputSource = new LocalInputSource(invoiceSplitterBytes, "default_sample.pdf");
var response = await client.EnqueueAndParseAsync(invoiceSplitterInputSource);
InvoiceSplitterV1 inference = response.Document.Inference;
@@ -43,7 +43,7 @@ public async Task GivenAPdf_ShouldExtractInvoicesStrict_MustSucceed()
await client.ParseAsync(extractedPdfsStrict[0].AsInputSource());
string testStringRstInvoice0 = PrepareInvoiceReturn(
- "Resources/v1/products/invoices/response_v4/summary_full_invoice_p1.rst", invoice0.Document);
+ Constants.V1ProductDir + "invoices/response_v4/summary_full_invoice_p1.rst", invoice0.Document);
double ratio = TestingUtilities.LevenshteinRatio(testStringRstInvoice0, invoice0.Document.ToString());
Assert.True(ratio >= 0.90);
diff --git a/tests/Mindee.IntegrationTests/V1/MindeeClientTest.cs b/tests/Mindee.IntegrationTests/V1/MindeeClientTest.cs
index 976b50a3..7c0a56a7 100644
--- a/tests/Mindee.IntegrationTests/V1/MindeeClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V1/MindeeClientTest.cs
@@ -25,7 +25,7 @@ public MindeeClientTest()
[Fact]
public async Task Parse_File_Standard_MultiplePages_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/file_types/pdf/multipage_cut-2.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage_cut-2.pdf");
var response = await _mindeeClient.ParseAsync(inputSource);
Assert.NotNull(response);
Assert.Equal("success", response.ApiRequest.Status);
@@ -40,7 +40,7 @@ public async Task Parse_File_Standard_MultiplePages_MustSucceed()
[Fact]
public async Task Parse_File_Standard_SinglePage_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var response = await _mindeeClient.ParseAsync(inputSource);
Assert.NotNull(response);
Assert.Equal("success", response.ApiRequest.Status);
@@ -80,7 +80,7 @@ await Assert.ThrowsAsync(
[Fact]
public async Task Parse_File_Cropper_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var predictOptions = new PredictOptions(cropper: true);
var response = await _mindeeClient.ParseAsync(inputSource, predictOptions);
Assert.NotNull(response);
@@ -97,7 +97,7 @@ public async Task Parse_File_Cropper_MustSucceed()
[Fact]
public async Task Parse_File_Standard_AllWords_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var predictOptions = new PredictOptions(allWords: true);
var response = await _mindeeClient.ParseAsync(inputSource, predictOptions);
Assert.NotNull(response);
@@ -115,7 +115,7 @@ public async Task Parse_File_Standard_AllWords_MustSucceed()
[Fact]
public async Task Parse_File_Standard_FullText_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/v1/products/international_id/default_sample.jpg");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "international_id/default_sample.jpg");
var predictOptions = new PredictOptions(fullText: true);
var response = await _mindeeClient.EnqueueAndParseAsync(inputSource, predictOptions);
Assert.NotNull(response);
@@ -131,7 +131,7 @@ public async Task Parse_File_Standard_FullText_MustSucceed()
[Fact]
public async Task Parse_File_Standard_AllWords_And_Cropper_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await _mindeeClient.ParseAsync(
inputSource, predictOptions);
@@ -151,7 +151,7 @@ public async Task Parse_File_Standard_AllWords_And_Cropper_MustSucceed()
[Fact]
public async Task Enqueue_File_Standard_SyncOnly_Async_MustFail()
{
- var inputSource = new LocalInputSource("Resources/v1/products/passport/default_sample.jpg");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "passport/default_sample.jpg");
await Assert.ThrowsAsync(
() => _mindeeClient.EnqueueAsync(inputSource));
}
@@ -159,7 +159,7 @@ await Assert.ThrowsAsync(
[Fact]
public async Task Enqueue_File_Standard_AsyncOnly_Async_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var response = await _mindeeClient.EnqueueAsync(inputSource);
Assert.NotNull(response);
@@ -178,7 +178,7 @@ public async Task Enqueue_File_Standard_AsyncOnly_Async_MustSucceed()
[Fact]
public async Task Enqueue_File_Standard_AsyncOnly_Sync_MustFail()
{
- var inputSource = new LocalInputSource("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
await Assert.ThrowsAsync(
() => _mindeeClient.ParseAsync(inputSource));
}
@@ -186,7 +186,7 @@ await Assert.ThrowsAsync(
[Fact]
public async Task EnqueueAndParse_File_Standard_AsyncOnly_Async_MustSucceed()
{
- var inputSource = new LocalInputSource("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var pollingOptions = new AsyncPollingOptions();
var response = await _mindeeClient.EnqueueAndParseAsync(
inputSource, pollingOptions: pollingOptions);
@@ -271,7 +271,7 @@ await Assert.ThrowsAsync(
public async Task Enqueue_File_Generated_AsyncOnly_Sync_MustFail()
{
var endpoint = new CustomEndpoint("international_id", "mindee", "2");
- var inputSource = new LocalInputSource("Resources/v1/products/international_id/default_sample.jpg");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "international_id/default_sample.jpg");
await Assert.ThrowsAsync(
() => _mindeeClient.ParseAsync(inputSource, endpoint));
}
@@ -280,7 +280,7 @@ await Assert.ThrowsAsync(
public async Task EnqueueAndParse_File_Generated_AsyncOnly_Async_MustSucceed()
{
var endpoint = new CustomEndpoint("international_id", "mindee", "2");
- var inputSource = new LocalInputSource("Resources/v1/products/international_id/default_sample.jpg");
+ var inputSource = new LocalInputSource(Constants.V1ProductDir + "international_id/default_sample.jpg");
var response = await _mindeeClient.EnqueueAndParseAsync(inputSource, endpoint);
Assert.NotNull(response);
diff --git a/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs b/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs
index 0be81dcf..adf6efed 100644
--- a/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs
+++ b/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs
@@ -18,9 +18,9 @@ public WorkflowTest()
var apiKey1 = Environment.GetEnvironmentVariable("Mindee__ApiKey");
_client = TestingUtilities.GetOrGenerateMindeeClient(apiKey1);
_ragMatchInputSource = new LocalInputSource(
- "Resources/v1/products/financial_document/default_sample.jpg");
+ Constants.V1ProductDir + "financial_document/default_sample.jpg");
_ragNoMatchInputSource = new LocalInputSource(
- "Resources/v1/products/invoices/default_sample.jpg");
+ Constants.V1ProductDir + "invoices/default_sample.jpg");
_workflowId = Environment.GetEnvironmentVariable("Workflow__ID") ?? "";
}
diff --git a/tests/Mindee.IntegrationTests/V2/MindeeClientV2Test.cs b/tests/Mindee.IntegrationTests/V2/MindeeClientV2Test.cs
index 2793ccbd..b37b35fb 100644
--- a/tests/Mindee.IntegrationTests/V2/MindeeClientV2Test.cs
+++ b/tests/Mindee.IntegrationTests/V2/MindeeClientV2Test.cs
@@ -42,7 +42,7 @@ public async Task Parse_File_Empty_MultiplePages_ParameterVariations_MustSucceed
bool rawText, bool polygon, bool confidence)
{
var inputSource = new LocalInputSource(
- "Resources/file_types/pdf/multipage_cut-2.pdf");
+ Constants.RootDir + "file_types/pdf/multipage_cut-2.pdf");
var inferenceParams = new InferenceParameters(
modelId: _findocModelId,
rag: false,
@@ -107,7 +107,7 @@ public async Task Parse_File_Empty_MultiplePages_ParameterVariations_MustSucceed
public async Task Parse_File_Filled_SinglePage_MustSucceed()
{
var inputSource = new LocalInputSource(
- "Resources/v1/products/financial_document/default_sample.jpg");
+ Constants.V1ProductDir + "financial_document/default_sample.jpg");
var inferenceParams = new InferenceParameters(
modelId: _findocModelId);
@@ -143,7 +143,7 @@ public async Task FailedWebhook_Retrieve_Job_MustSucceed()
{
string? webhookId = Environment.GetEnvironmentVariable("MindeeV2__Failure__Webhook__Id");
- var inputSource = new LocalInputSource("Resources/file_types/pdf/multipage_cut-1.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage_cut-1.pdf");
var inferenceParams = new InferenceParameters(
modelId: _findocModelId, webhookIds: new List { webhookId });
@@ -193,7 +193,7 @@ public async Task FailedWebhook_Retrieve_Job_MustSucceed()
[Fact]
public async Task Invalid_Model_MustThrowError()
{
- var inputSource = new LocalInputSource("Resources/file_types/pdf/multipage_cut-2.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage_cut-2.pdf");
var predictOptions = new InferenceParameters("INVALID MODEL ID");
var ex = await Assert.ThrowsAsync(
() => _mindeeClientV2.EnqueueInferenceAsync(inputSource, predictOptions));
diff --git a/tests/Mindee.UnitTests/Constants.cs b/tests/Mindee.UnitTests/Constants.cs
new file mode 100644
index 00000000..6aaa7e7b
--- /dev/null
+++ b/tests/Mindee.UnitTests/Constants.cs
@@ -0,0 +1,12 @@
+namespace Mindee.UnitTests
+{
+ public static class Constants
+ {
+ public const string RootDir = "Resources/";
+
+ public const string V1RootDir = RootDir + "v1/";
+ public const string V1ProductDir = V1RootDir + "products/";
+
+ public const string V2RootDir = RootDir + "v2/";
+ }
+}
diff --git a/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs b/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs
index 966189da..311b8df3 100644
--- a/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs
+++ b/tests/Mindee.UnitTests/Extraction/ImageExtractorTest.cs
@@ -12,7 +12,7 @@ public class ImageExtractorTest
[Fact]
public async Task GivenAnImage_ShouldExtractPositionFields()
{
- var image = new LocalInputSource("Resources/v1/products/multi_receipts_detector/default_sample.jpg");
+ var image = new LocalInputSource(Constants.V1ProductDir + "multi_receipts_detector/default_sample.jpg");
var response = await GetMultiReceiptsDetectorPrediction("complete");
var inference = response.Document.Inference;
@@ -41,7 +41,7 @@ public async Task GivenAnImage_ShouldExtractPositionFields()
[Fact]
public async Task GivenAnImage_ShouldExtractValueFields()
{
- var image = new LocalInputSource("Resources/v1/products/barcode_reader/default_sample.jpg");
+ var image = new LocalInputSource(Constants.V1ProductDir + "barcode_reader/default_sample.jpg");
var response = await GetBarcodeReaderPrediction("complete");
var inference = response.Document.Inference;
@@ -76,7 +76,7 @@ public async Task GivenAnImage_ShouldExtractValueFields()
public async Task GivenAPdf_ShouldExtractPositionFields()
{
var image = new LocalInputSource(
- "Resources/v1/products/multi_receipts_detector/multipage_sample.pdf");
+ Constants.V1ProductDir + "multi_receipts_detector/multipage_sample.pdf");
var response = await GetMultiReceiptsDetectorPrediction("multipage_sample");
var inference = response.Document.Inference;
@@ -105,7 +105,7 @@ public async Task GivenAPdf_ShouldExtractPositionFields()
private static async Task> GetMultiReceiptsDetectorPrediction(
string name)
{
- string fileName = $"Resources/v1/products/multi_receipts_detector/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/multi_receipts_detector/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
@@ -113,7 +113,7 @@ private static async Task> GetMultiRece
private static async Task> GetBarcodeReaderPrediction(string name)
{
- string fileName = $"Resources/v1/products/barcode_reader/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/barcode_reader/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs b/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs
index 4b2f3928..3492e7a6 100644
--- a/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs
+++ b/tests/Mindee.UnitTests/Extraction/PdfExtractorTest.cs
@@ -11,7 +11,7 @@ public class PdfExtractorTest
[Fact]
public void GivenAnImage_ShouldExtractAPDF()
{
- var jpg = "Resources/v1/products/invoices/default_sample.jpg";
+ var jpg = Constants.V1ProductDir + "invoices/default_sample.jpg";
var localInput = new LocalInputSource(jpg);
Assert.False(localInput.IsPdf());
var extractor = new PdfExtractor(localInput);
@@ -21,7 +21,7 @@ public void GivenAnImage_ShouldExtractAPDF()
[Fact]
public async Task GivenAPDF_ShouldExtractInvoicesNoStrict()
{
- var pdf = new LocalInputSource("Resources/v1/products/invoice_splitter/invoice_5p.pdf");
+ var pdf = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/invoice_5p.pdf");
var response = await GetPrediction();
Assert.NotNull(response);
var inference = response.Document.Inference;
@@ -41,7 +41,7 @@ public async Task GivenAPDF_ShouldExtractInvoicesNoStrict()
[Fact]
public async Task GivenAPDF_ShouldExtractInvoicesStrict()
{
- var pdf = new LocalInputSource("Resources/v1/products/invoice_splitter/invoice_5p.pdf");
+ var pdf = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/invoice_5p.pdf");
var response = await GetPrediction();
Assert.NotNull(response);
var inference = response.Document.Inference;
@@ -58,7 +58,7 @@ public async Task GivenAPDF_ShouldExtractInvoicesStrict()
}
private async Task> GetPrediction()
{
- const string fileName = "Resources/v1/products/invoice_splitter/response_v1/complete.json";
+ const string fileName = Constants.V1ProductDir + "invoice_splitter/response_v1/complete.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.DocumentQueueGetAsync("hello");
}
diff --git a/tests/Mindee.UnitTests/Input/LocalInputSourceTest.cs b/tests/Mindee.UnitTests/Input/LocalInputSourceTest.cs
index 28dd5bab..bafa1931 100644
--- a/tests/Mindee.UnitTests/Input/LocalInputSourceTest.cs
+++ b/tests/Mindee.UnitTests/Input/LocalInputSourceTest.cs
@@ -14,44 +14,44 @@ public class LocalInputSourceTest
[Fact]
public void Can_Load_Type_ImageFiles()
{
- Assert.IsType(new LocalInputSource("Resources/file_types/receipt.jpg"));
- Assert.IsType(new LocalInputSource("Resources/file_types/receipt.heic"));
- Assert.IsType(new LocalInputSource("Resources/file_types/receipt.jpga"));
- Assert.IsType(new LocalInputSource("Resources/file_types/receipt.tif"));
- Assert.IsType(new LocalInputSource("Resources/file_types/receipt.tiff"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/receipt.heic"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/receipt.jpga"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/receipt.tif"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/receipt.tiff"));
}
[Fact]
public void Can_Load_Type_PDF()
{
- Assert.IsType(new LocalInputSource("Resources/file_types/pdf/blank_1.pdf"));
+ Assert.IsType(new LocalInputSource(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
}
[Fact]
public void DoesNot_Load_InvalidFile()
{
Assert.Throws(
- () => new LocalInputSource("Resources/file_types/receipt.txt"));
+ () => new LocalInputSource(Constants.RootDir + "file_types/receipt.txt"));
}
[Fact]
public void Can_Load_Using_FileInfo()
{
- FileInfo fileInfo = new FileInfo("Resources/file_types/receipt.jpg");
+ FileInfo fileInfo = new FileInfo(Constants.RootDir + "file_types/receipt.jpg");
Assert.IsType(new LocalInputSource(fileInfo));
}
[Fact]
public void Can_Load_Using_FileStream()
{
- Stream fileStream = File.OpenRead("Resources/file_types/receipt.jpg");
+ Stream fileStream = File.OpenRead(Constants.RootDir + "file_types/receipt.jpg");
Assert.IsType(new LocalInputSource(fileStream, "receipt.jpg"));
}
[Fact]
public void Can_Load_Using_MemoryStream()
{
- var fileBytes = File.ReadAllBytes("Resources/file_types/receipt.jpg");
+ var fileBytes = File.ReadAllBytes(Constants.RootDir + "file_types/receipt.jpg");
var memoryStream = new MemoryStream(fileBytes);
Assert.IsType(new LocalInputSource(memoryStream, "receipt.jpg"));
}
@@ -67,9 +67,9 @@ public void Can_Load_Using_FileBytes()
[Fact]
public void PDF_Input_Has_Text()
{
- var hasSourceText = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
- var hasNoSourceText = new LocalInputSource("Resources/file_types/pdf/blank_1.pdf");
- var hasNoSourceTextSinceItsImage = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var hasSourceText = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
+ var hasNoSourceText = new LocalInputSource(Constants.RootDir + "file_types/pdf/blank_1.pdf");
+ var hasNoSourceTextSinceItsImage = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
Assert.True(hasSourceText.HasSourceText());
Assert.False(hasNoSourceText.HasSourceText());
Assert.False(hasNoSourceTextSinceItsImage.HasSourceText());
@@ -78,11 +78,11 @@ public void PDF_Input_Has_Text()
[Fact]
public void Image_Quality_Compress_From_Input_Source()
{
- var receiptInput = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var receiptInput = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
receiptInput.Compress(40);
File.WriteAllBytes("Resources/output/compress_indirect.jpg", receiptInput.FileBytes);
Assert.True(true);
- var initialFileInfo = new FileInfo("Resources/file_types/receipt.jpg");
+ var initialFileInfo = new FileInfo(Constants.RootDir + "file_types/receipt.jpg");
var renderedFileInfo = new FileInfo("Resources/output/compress_indirect.jpg");
Assert.True(renderedFileInfo.Length < initialFileInfo.Length);
}
@@ -92,7 +92,7 @@ public void Image_Quality_Compresses_From_Compressor()
{
// Note: input image has a quality of ~85, but Skiasharp messes with headers, which results in a different
// total byte size, which means we can't just compare quality 75 to quality 75.
- var receiptInput = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var receiptInput = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var compresses = new List
{
ImageCompressor.CompressImage(receiptInput.FileBytes, 100),
@@ -107,7 +107,7 @@ public void Image_Quality_Compresses_From_Compressor()
File.WriteAllBytes("Resources/output/compress10.jpg", compresses[3]);
File.WriteAllBytes("Resources/output/compress1.jpg", compresses[4]);
Assert.True(true);
- var initialFileInfo = new FileInfo("Resources/file_types/receipt.jpg");
+ var initialFileInfo = new FileInfo(Constants.RootDir + "file_types/receipt.jpg");
var renderedFileInfos = new List
{
new("Resources/output/compress100.jpg"),
@@ -126,10 +126,10 @@ public void Image_Quality_Compresses_From_Compressor()
[Fact]
public void Image_Resize_From_InputSource()
{
- var imageResizeInput = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var imageResizeInput = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
imageResizeInput.Compress(maxWidth: 250, maxHeight: 1000);
File.WriteAllBytes("Resources/output/resize_indirect.jpg", imageResizeInput.FileBytes);
- var initialFileInfo = new FileInfo("Resources/file_types/receipt.jpg");
+ var initialFileInfo = new FileInfo(Constants.RootDir + "file_types/receipt.jpg");
var renderedFileInfo = new FileInfo("Resources/output/resize_indirect.jpg");
Assert.True(renderedFileInfo.Length < initialFileInfo.Length);
@@ -141,7 +141,7 @@ public void Image_Resize_From_InputSource()
[Fact]
public void Image_Resize_From_Compressor()
{
- var imageResizeInput = new LocalInputSource("Resources/file_types/receipt.jpg");
+ var imageResizeInput = new LocalInputSource(Constants.RootDir + "file_types/receipt.jpg");
var resizes = new List
{
ImageCompressor.CompressImage(imageResizeInput.FileBytes, 75, 500),
@@ -153,7 +153,7 @@ public void Image_Resize_From_Compressor()
File.WriteAllBytes("Resources/output/resize250x500.jpg", resizes[1]);
File.WriteAllBytes("Resources/output/resize500x250.jpg", resizes[2]);
File.WriteAllBytes("Resources/output/resizenullx250.jpg", resizes[3]);
- var initialFileInfo = new FileInfo("Resources/file_types/receipt.jpg");
+ var initialFileInfo = new FileInfo(Constants.RootDir + "file_types/receipt.jpg");
var renderedFileInfos = new List
{
new("Resources/output/resize500xnull.jpg"),
@@ -170,10 +170,10 @@ public void Image_Resize_From_Compressor()
[Fact]
public void Pdf_Compress_From_InputSource()
{
- var pdfResizeInput = new LocalInputSource("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var pdfResizeInput = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
pdfResizeInput.Compress(quality: 75);
File.WriteAllBytes("Resources/output/resize_indirect.pdf", pdfResizeInput.FileBytes);
- var initialFileInfo = new FileInfo("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var initialFileInfo = new FileInfo(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var renderedFileInfo = new FileInfo("Resources/output/resize_indirect.pdf");
Assert.True(renderedFileInfo.Length < initialFileInfo.Length);
}
@@ -181,7 +181,7 @@ public void Pdf_Compress_From_InputSource()
[Fact]
public void Pdf_Compress_From_Compressor()
{
- var pdfResizeInput = new LocalInputSource("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var pdfResizeInput = new LocalInputSource(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var resizes = new List
{
PdfCompressor.CompressPdf(pdfResizeInput.FileBytes),
@@ -193,7 +193,7 @@ public void Pdf_Compress_From_Compressor()
File.WriteAllBytes("Resources/output/compress75.pdf", resizes[1]);
File.WriteAllBytes("Resources/output/compress50.pdf", resizes[2]);
File.WriteAllBytes("Resources/output/compress10.pdf", resizes[3]);
- var initialFileInfo = new FileInfo("Resources/v1/products/invoice_splitter/default_sample.pdf");
+ var initialFileInfo = new FileInfo(Constants.V1ProductDir + "invoice_splitter/default_sample.pdf");
var renderedFileInfos = new List
{
new("Resources/output/compress85.pdf"),
@@ -212,7 +212,7 @@ public void Pdf_Compress_With_Text_Keeps_Text()
{
lock (DocLib.Instance)
{
- var initialWithText = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
+ var initialWithText = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
var compressedWithText = PdfCompressor.CompressPdf(initialWithText.FileBytes, 100, true, false);
using var originalReader = DocLib.Instance.GetDocReader(initialWithText.FileBytes, new PageDimensions(1));
using var compressedReader = DocLib.Instance.GetDocReader(compressedWithText, new PageDimensions(1));
@@ -230,7 +230,7 @@ public void Pdf_Compress_With_Text_Does_Not_Compress()
{
lock (DocLib.Instance)
{
- var initialWithText = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
+ var initialWithText = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
var compressedWithText = PdfCompressor.CompressPdf(initialWithText.FileBytes, 50);
Assert.Equal(compressedWithText, initialWithText.FileBytes);
}
@@ -239,7 +239,7 @@ public void Pdf_Compress_With_Text_Does_Not_Compress()
[Fact]
public void ApplyPageOperation_KeepFirstPage_Should_Work()
{
- var inputSource = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
var pageOptions = new PageOptions(
operation: PageOptionsOperation.KeepOnly
, pageIndexes: new short[] { 0 });
@@ -249,7 +249,7 @@ public void ApplyPageOperation_KeepFirstPage_Should_Work()
[Fact]
public void ApplyPageOperation_Keep5FirstPages_Should_Work()
{
- var initialWithText = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
+ var initialWithText = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
// Only for documents having 10 or more pages:
// Remove the first 5 pages
var pageOptions = new PageOptions(
@@ -264,7 +264,7 @@ public void ApplyPageOperation_Keep5FirstPages_Should_Work()
[Fact]
public void ApplyPageOperation_Keep3VariousPages_Should_Work()
{
- var initialWithText = new LocalInputSource("Resources/file_types/pdf/multipage.pdf");
+ var initialWithText = new LocalInputSource(Constants.RootDir + "file_types/pdf/multipage.pdf");
// Only for documents having 2 or more pages:
// Keep only these pages: first, penultimate, last
diff --git a/tests/Mindee.UnitTests/Pdf/PdfOperationTest.cs b/tests/Mindee.UnitTests/Pdf/PdfOperationTest.cs
index 62acf635..d153b6ee 100644
--- a/tests/Mindee.UnitTests/Pdf/PdfOperationTest.cs
+++ b/tests/Mindee.UnitTests/Pdf/PdfOperationTest.cs
@@ -19,7 +19,7 @@ public PdfOperationTest()
public void Split_Wants1Page_MustGetOnly1Page()
{
var splitQuery = new SplitQuery(
- File.ReadAllBytes("Resources/file_types/pdf/multipage.pdf"),
+ File.ReadAllBytes(Constants.RootDir + "file_types/pdf/multipage.pdf"),
new PageOptions(new short[] { 1 }));
var splitPdf = _pdfOperation.Split(splitQuery);
@@ -34,7 +34,7 @@ public void Split_Wants1Page_MustGetOnly1Page()
public void Split_Wants2Pages_MustGet2Pages()
{
var splitQuery = new SplitQuery(File.ReadAllBytes(
- "Resources/file_types/pdf/multipage.pdf"),
+ Constants.RootDir + "file_types/pdf/multipage.pdf"),
new PageOptions(new short[] { 0, 1 }));
var splitPdf = _pdfOperation.Split(splitQuery);
@@ -50,7 +50,7 @@ public void Split_WantsTooManyPages_MustFail()
{
var pageOptions = new PageOptions(new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
var splitQuery = new SplitQuery(File.ReadAllBytes(
- "Resources/file_types/pdf/multipage.pdf"), pageOptions);
+ Constants.RootDir + "file_types/pdf/multipage.pdf"), pageOptions);
Assert.Throws(() => _pdfOperation.Split(splitQuery));
}
@@ -60,7 +60,7 @@ public void Split_WantsTooManyPages_MustFail()
public void Split_OtherThanAPdf_MustFail()
{
var splitQuery = new SplitQuery(File.ReadAllBytes(
- "Resources/file_types/receipt.jpga"),
+ Constants.RootDir + "file_types/receipt.jpga"),
new PageOptions(new short[] { 0, 1, 2 }));
Assert.Throws(() => _pdfOperation.Split(splitQuery));
@@ -71,7 +71,7 @@ public void Split_OtherThanAPdf_MustFail()
public void Split_ShouldCutTheFirstAndThe2LastPages_MustSuccess()
{
var splitQuery = new SplitQuery(File.ReadAllBytes(
- "Resources/file_types/pdf/multipage.pdf"),
+ Constants.RootDir + "file_types/pdf/multipage.pdf"),
new PageOptions(new short[] { 0, -2, -1 }));
var splitPdf = _pdfOperation.Split(splitQuery);
@@ -86,7 +86,7 @@ public void Split_ShouldCutTheFirstAndThe2LastPages_MustSuccess()
public void Split_ShouldRemovePages_MustSuccess()
{
var splitQuery = new SplitQuery(
- File.ReadAllBytes("Resources/file_types/pdf/multipage.pdf")
+ File.ReadAllBytes(Constants.RootDir + "file_types/pdf/multipage.pdf")
, new PageOptions(
new short[] { 0, 1, 2 }
, PageOptionsOperation.Remove));
@@ -103,7 +103,7 @@ public void Split_ShouldRemovePages_MustSuccess()
public void Split_ShouldNotRemovePagesBecauseMinPagesAreNotMet()
{
var splitQuery = new SplitQuery(
- File.ReadAllBytes("Resources/file_types/pdf/multipage_cut-2.pdf")
+ File.ReadAllBytes(Constants.RootDir + "file_types/pdf/multipage_cut-2.pdf")
, new PageOptions(
new short[] { 0 }
, PageOptionsOperation.Remove
diff --git a/tests/Mindee.UnitTests/V1/Http/MindeeApiTest.cs b/tests/Mindee.UnitTests/V1/Http/MindeeApiTest.cs
index e92d1499..aa21bc6d 100644
--- a/tests/Mindee.UnitTests/V1/Http/MindeeApiTest.cs
+++ b/tests/Mindee.UnitTests/V1/Http/MindeeApiTest.cs
@@ -19,7 +19,7 @@ public async Task Predict_WithWrongKey()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.BadRequest,
- File.ReadAllText("Resources/v1/errors/error_401_invalid_token.json")
+ File.ReadAllText(Constants.V1RootDir + "errors/error_401_invalid_token.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -36,7 +36,7 @@ public async Task Predict_WithValidResponse()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.OK,
- File.ReadAllText("Resources/v1/products/invoices/response_v4/complete.json")
+ File.ReadAllText(Constants.V1ProductDir + "invoices/response_v4/complete.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -45,8 +45,8 @@ public async Task Predict_WithValidResponse()
UnitTestBase.GetFakePredictParameter()
);
- var expectedParse = File.ReadAllText("Resources/v1/products/invoices/response_v4/summary_full.rst");
- var expectedJson = File.ReadAllText("Resources/v1/products/invoices/response_v4/complete.json");
+ var expectedParse = File.ReadAllText(Constants.V1ProductDir + "invoices/response_v4/summary_full.rst");
+ var expectedJson = File.ReadAllText(Constants.V1ProductDir + "invoices/response_v4/complete.json");
Assert.NotNull(response);
Assert.Equal(expectedParse, response.Document.ToString());
@@ -58,7 +58,7 @@ public async Task Predict_WithErrorResponse()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.BadRequest,
- File.ReadAllText("Resources/v1/errors/error_400_with_object_in_detail.json")
+ File.ReadAllText(Constants.V1RootDir + "errors/error_400_with_object_in_detail.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -73,7 +73,7 @@ public async Task Predict_500Error()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.InternalServerError,
- File.ReadAllText("Resources/v1/errors/error_500_inference_fail.json")
+ File.ReadAllText(Constants.V1RootDir + "errors/error_500_inference_fail.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
await Assert.ThrowsAsync(
@@ -87,7 +87,7 @@ public async Task Predict_429Error()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
(HttpStatusCode)429,
- File.ReadAllText("Resources/v1/errors/error_429_too_many_requests.json")
+ File.ReadAllText(Constants.V1RootDir + "errors/error_429_too_many_requests.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -102,7 +102,7 @@ public async Task Predict_401Error()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.Unauthorized,
- File.ReadAllText("Resources/v1/errors/error_401_invalid_token.json")
+ File.ReadAllText(Constants.V1RootDir + "errors/error_401_invalid_token.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -117,7 +117,7 @@ public async Task PredictAsyncPostAsync_WithFailForbidden()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.Forbidden,
- File.ReadAllText("Resources/v1/async/post_fail_forbidden.json")
+ File.ReadAllText(Constants.V1RootDir + "async/post_fail_forbidden.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -132,7 +132,7 @@ public async Task PredictAsyncPostAsync_WithSuccess()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.OK,
- File.ReadAllText("Resources/v1/async/post_success.json")
+ File.ReadAllText(Constants.V1RootDir + "async/post_success.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -152,7 +152,7 @@ public async Task DocumentQueueGetAsync_WithJobProcessing()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.OK,
- File.ReadAllText("Resources/v1/async/get_processing.json")
+ File.ReadAllText(Constants.V1RootDir + "async/get_processing.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -171,7 +171,7 @@ public async Task DocumentQueueGetAsync_WithJobFailed()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.OK,
- File.ReadAllText("Resources/v1/async/get_failed_job_error.json")
+ File.ReadAllText(Constants.V1RootDir + "async/get_failed_job_error.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
@@ -185,7 +185,7 @@ public async Task DocumentQueueGetAsync_WithSuccess()
{
var serviceProvider = UnitTestBase.InitServiceProviderV1(
HttpStatusCode.OK,
- File.ReadAllText("Resources/v1/async/get_completed.json")
+ File.ReadAllText(Constants.V1RootDir + "async/get_completed.json")
);
var mindeeApi = serviceProvider.GetRequiredService();
diff --git a/tests/Mindee.UnitTests/V1/Input/LocalResponseTest.cs b/tests/Mindee.UnitTests/V1/Input/LocalResponseTest.cs
index 7ec40c66..1e16aa1f 100644
--- a/tests/Mindee.UnitTests/V1/Input/LocalResponseTest.cs
+++ b/tests/Mindee.UnitTests/V1/Input/LocalResponseTest.cs
@@ -12,7 +12,7 @@ public class LocalResponseTest
private const string Signature = "5ed1673e34421217a5dbfcad905ee62261a3dd66c442f3edd19302072bbf70d0";
// File which the signature applies to.
- private const string FilePath = "Resources/v1/async/get_completed_empty.json";
+ private const string FilePath = Constants.V1RootDir + "async/get_completed_empty.json";
[Fact]
public void LoadDocument_WithFile_MustReturnValidLocalResponse()
diff --git a/tests/Mindee.UnitTests/V1/MindeeClientTest.cs b/tests/Mindee.UnitTests/V1/MindeeClientTest.cs
index 799fc06f..bc828e1a 100644
--- a/tests/Mindee.UnitTests/V1/MindeeClientTest.cs
+++ b/tests/Mindee.UnitTests/V1/MindeeClientTest.cs
@@ -22,7 +22,7 @@ public async Task Parse_CustomProduct_WithFile_NoOptions()
var mindeeClient = MakeCustomMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response = await mindeeClient.ParseAsync(
inputSource, endpoint);
@@ -56,7 +56,7 @@ public async Task Parse_CustomProduct_WithFile_PredictOptions()
var mindeeClient = MakeCustomMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await mindeeClient.ParseAsync(
inputSource,
@@ -76,7 +76,7 @@ public async Task Parse_GeneratedProduct_WithFile_NoOptions()
var mindeeClient = MakeGeneratedMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response = await mindeeClient.ParseAsync(
inputSource, endpoint);
@@ -93,7 +93,7 @@ public async Task Parse_GeneratedProduct_WithFile_PredictOptions()
var mindeeClient = MakeGeneratedMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await mindeeClient.ParseAsync(
inputSource, endpoint, predictOptions);
@@ -128,7 +128,7 @@ public async Task Enqueue_GeneratedProduct_WithFile_NoOptions()
var mindeeClient = MakeGeneratedMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource("Resources/file_types/pdf/blank_1.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/blank_1.pdf");
var response = await mindeeClient.EnqueueAsync(
inputSource, endpoint);
@@ -145,7 +145,7 @@ public async Task Enqueue_GeneratedProduct_WithFile_PredictOptions()
var mindeeClient = MakeGeneratedMindeeClient(predictable);
var endpoint = new CustomEndpoint("", "");
- var inputSource = new LocalInputSource("Resources/file_types/pdf/blank_1.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/blank_1.pdf");
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await mindeeClient.EnqueueAsync(
inputSource, endpoint, predictOptions);
@@ -194,7 +194,7 @@ public async Task Parse_StandardProduct_WithFile_NoOptions()
var predictable = new Mock();
var mindeeClient = MakeStandardMindeeClient(predictable);
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
Assert.Equal(1, inputSource.GetPageCount());
var document = await mindeeClient.ParseAsync(
inputSource);
@@ -227,7 +227,8 @@ public async Task Parse_StandardProduct_WithFile_PredictOptions()
var predictable = new Mock();
var mindeeClient = MakeStandardMindeeClient(predictable);
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(
+ new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await mindeeClient.ParseAsync(
inputSource, predictOptions);
@@ -244,7 +245,8 @@ public async Task Parse_StandardProduct_WithFile_PageOptions()
var predictable = new Mock();
var mindeeClient = MakeStandardMindeeClient(predictable);
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/multipage.pdf"));
+ var inputSource = new LocalInputSource(
+ new FileInfo(Constants.RootDir + "file_types/pdf/multipage.pdf"));
Assert.Equal(12, inputSource.GetPageCount());
var pageOptions = new PageOptions(pageIndexes: new short[] { 1, 2, 3 });
var response = await mindeeClient.ParseAsync(
@@ -263,7 +265,7 @@ public async Task Parse_StandardProduct_WithByteArray_NoOptions()
var mindeeClient = MakeStandardMindeeClient(predictable);
var inputSource = new LocalInputSource(
- File.ReadAllBytes("Resources/file_types/pdf/blank_1.pdf"),
+ File.ReadAllBytes(Constants.RootDir + "file_types/pdf/blank_1.pdf"),
"blank_1.pdf"
);
var response = await mindeeClient.ParseAsync(
@@ -281,7 +283,7 @@ public async Task Enqueue_StandardProduct_WithFile_NoOptions()
var predictable = new Mock();
var mindeeClient = MakeStandardMindeeClient(predictable);
- var inputSource = new LocalInputSource("Resources/file_types/pdf/blank_1.pdf");
+ var inputSource = new LocalInputSource(Constants.RootDir + "file_types/pdf/blank_1.pdf");
var response = await mindeeClient.EnqueueAsync(inputSource);
Assert.NotNull(response);
@@ -311,7 +313,8 @@ public async Task Enqueue_StandardProduct_WithFile_PredictOptions()
var predictable = new Mock();
var mindeeClient = MakeStandardMindeeClient(predictable);
- var inputSource = new LocalInputSource("Resources/file_types/pdf/blank_1.pdf");
+ var inputSource = new LocalInputSource(
+ Constants.RootDir + "file_types/pdf/blank_1.pdf");
var predictOptions = new PredictOptions(allWords: true, cropper: true);
var response = await mindeeClient.EnqueueAsync(inputSource, predictOptions);
@@ -353,13 +356,13 @@ public void GivenJsonInput_WhenSync_ShouldDeserializeCorrectly()
var mindeeClient = MakeStandardMindeeClient(predictable);
var localresponse = new LocalResponse(
- new FileInfo("Resources/v1/products/invoices/response_v4/complete.json"));
+ new FileInfo(Constants.V1ProductDir + "invoices/response_v4/complete.json"));
var response = mindeeClient.LoadPrediction(localresponse);
Assert.NotNull(response);
Assert.Equal(
response.Document.ToString(),
- File.ReadAllText("Resources/v1/products/invoices/response_v4/summary_full.rst"));
+ File.ReadAllText(Constants.V1ProductDir + "invoices/response_v4/summary_full.rst"));
}
[Fact]
@@ -369,13 +372,13 @@ public void GivenJsonInput_WhenAsync_ShouldDeserializeCorrectly()
var mindeeClient = MakeStandardMindeeClient(predictable);
var localresponse = new LocalResponse(
- new FileInfo("Resources/v1/products/international_id/response_v2/complete.json"));
+ new FileInfo(Constants.V1ProductDir + "international_id/response_v2/complete.json"));
var response = mindeeClient.LoadPrediction(localresponse);
Assert.NotNull(response);
Assert.Equal(
response.Document.ToString(),
- File.ReadAllText("Resources/v1/products/international_id/response_v2/summary_full.rst"));
+ File.ReadAllText(Constants.V1ProductDir + "international_id/response_v2/summary_full.rst"));
}
private IPdfOperation GetDefaultPdfOperation() => new DocNetApi(new NullLogger());
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/AsyncPredictResponseTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/AsyncPredictResponseTest.cs
index acc32b40..fd84da1a 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/AsyncPredictResponseTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/AsyncPredictResponseTest.cs
@@ -13,7 +13,7 @@ public class AsyncPredictResponseTest
public async Task WhenAsyncPost_ReturnsErrorForbidden_MustBeDeserialized()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/async/post_fail_forbidden.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "async/post_fail_forbidden.json").OpenRead());
Assert.NotNull(response);
Assert.Equal("failure", response.ApiRequest.Status);
@@ -25,7 +25,7 @@ public async Task WhenAsyncPost_ReturnsErrorForbidden_MustBeDeserialized()
public async Task WhenAsyncPost_ReturnsSuccess_MustBeDeserialized()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/async/post_success.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "async/post_success.json").OpenRead());
Assert.NotNull(response);
Assert.Equal("success", response.ApiRequest.Status);
@@ -40,7 +40,7 @@ public async Task WhenAsyncPost_ReturnsSuccess_MustBeDeserialized()
public async Task WhenAsyncGet_ReturnsCompleted_MustBeDeserialized()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/async/get_completed.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "async/get_completed.json").OpenRead());
Assert.NotNull(response);
Assert.Equal("success", response.ApiRequest.Status);
@@ -56,7 +56,7 @@ public async Task WhenAsyncGet_ReturnsCompleted_MustBeDeserialized()
public async Task WhenAsyncGet_ReturnsFailedJob_MustBeDeserialized()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/async/get_failed_job_error.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "async/get_failed_job_error.json").OpenRead());
Assert.NotNull(response);
Assert.Equal("success", response.ApiRequest.Status);
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/CropperTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/CropperTest.cs
index 992dcebe..5a7126f8 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/CropperTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/CropperTest.cs
@@ -11,7 +11,7 @@ public class CropperTest
public async Task Should_GetCropperResult()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/extras/cropper/complete.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "extras/cropper/complete.json").OpenRead());
Assert.NotNull(response);
Assert.NotEmpty(response.Document.Inference.Pages);
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/ErrorTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/ErrorTest.cs
index be4869b8..39f867e8 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/ErrorTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/ErrorTest.cs
@@ -10,7 +10,7 @@ public class ErrorTest
public async Task Given_Details_As_object_MustBeDeserialized()
{
var error = await JsonSerializer.DeserializeAsync(
- new FileInfo("Resources/v1/errors/with_object_response_in_detail.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "errors/with_object_response_in_detail.json").OpenRead());
Assert.NotNull(error);
Assert.NotNull(error.Details);
@@ -21,7 +21,7 @@ public async Task Given_Details_As_object_MustBeDeserialized()
public async Task Given_Details_As_String_MustBeDeserialized()
{
var error = await JsonSerializer.DeserializeAsync(
- new FileInfo("Resources/v1/errors/with_string_response_in_detail.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "errors/with_string_response_in_detail.json").OpenRead());
Assert.NotNull(error);
Assert.NotNull(error.Details);
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
index d3e9c0a3..adc0c39f 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
@@ -15,7 +15,7 @@ public class FullTextOcrTest
private Inference LoadInference()
{
- var json = File.ReadAllText("Resources/v1/extras/full_text_ocr/complete.json");
+ var json = File.ReadAllText(Constants.V1RootDir + "extras/full_text_ocr/complete.json");
var prediction = JsonSerializer.Deserialize>(json, JsonOptions);
if (prediction == null)
{
@@ -26,7 +26,7 @@ private Inference LoadInfe
private List> LoadPages()
{
- var json = File.ReadAllText("Resources/v1/extras/full_text_ocr/complete.json");
+ var json = File.ReadAllText(Constants.V1RootDir + "extras/full_text_ocr/complete.json");
var prediction = JsonSerializer.Deserialize>(json, JsonOptions);
if (prediction == null)
{
@@ -38,7 +38,7 @@ private List> LoadPages()
[Fact]
public void Should_GetFullTextOcrResult()
{
- var expectedText = File.ReadAllLines("Resources/v1/extras/full_text_ocr/full_text_ocr.txt");
+ var expectedText = File.ReadAllLines(Constants.V1RootDir + "extras/full_text_ocr/full_text_ocr.txt");
var pages = LoadPages();
var inference = LoadInference();
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/OcrTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/OcrTest.cs
index c1e0e862..0a17ddcc 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/OcrTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/OcrTest.cs
@@ -10,7 +10,7 @@ public class OcrTest
private async Task LoadOcr()
{
var response = await JsonSerializer.DeserializeAsync>(
- new FileInfo("Resources/v1/extras/ocr/complete.json").OpenRead());
+ new FileInfo(Constants.V1RootDir + "extras/ocr/complete.json").OpenRead());
Assert.NotNull(response);
Assert.NotNull(response.Document.Ocr);
@@ -30,7 +30,7 @@ public async Task ShouldHaveCorrectWordCount()
public async Task StringShouldBeOrdered()
{
var ocr = await LoadOcr();
- var expected = File.ReadAllText("Resources/v1/extras/ocr/ocr.txt");
+ var expected = File.ReadAllText(Constants.V1RootDir + "extras/ocr/ocr.txt");
Assert.Equal(expected, ocr.ToString());
}
}
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Custom/CustomV1WithLineItemsTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Custom/CustomV1WithLineItemsTest.cs
index 47927ee4..6c0104a6 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Custom/CustomV1WithLineItemsTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Custom/CustomV1WithLineItemsTest.cs
@@ -11,7 +11,7 @@ public class CustomV1WithLineItemsTest
public async Task BuildLineItems_SingeTable01()
{
var mindeeAPi = GetMindeeApiForCustom(
- fileName: "Resources/v1/products/custom/response_v1/line_items/single_table_01.json");
+ fileName: Constants.V1ProductDir + "custom/response_v1/line_items/single_table_01.json");
var fieldNamesToLineItems = new List()
{
"beneficiary_name",
@@ -46,7 +46,7 @@ public async Task BuildLineItems_SingeTable01()
public async Task BuildLineItems_MultipleTables01()
{
var mindeeAPi = GetMindeeApiForCustom(
- fileName: "Resources/v1/products/custom/response_v1/line_items/multiple_tables_01.json");
+ fileName: Constants.V1ProductDir + "custom/response_v1/line_items/multiple_tables_01.json");
var earningsAnchor = new Anchor(name: "earnings_description", tolerance: 0.002d);
var earningsFields = new List
@@ -94,7 +94,7 @@ public async Task BuildLineItems_MultipleTables01()
public async Task BuildLineItems_MultipleTables02()
{
var mindeeAPi = GetMindeeApiForCustom(
- fileName: "Resources/v1/products/custom/response_v1/line_items/multiple_tables_02.json");
+ fileName: Constants.V1ProductDir + "custom/response_v1/line_items/multiple_tables_02.json");
var earningsAnchor = new Anchor(name: "earnings_description", tolerance: 0.002d);
var earningsFields = new List
@@ -138,7 +138,7 @@ public async Task BuildLineItems_MultipleTables02()
Assert.Equal("ZZ Disability", taxesLastLine.Fields["taxes_description"].Content);
}
- private MindeeApi GetMindeeApiForCustom(string fileName = "Resources/v1/products/custom/response_v1/complete.json")
+ private MindeeApi GetMindeeApiForCustom(string fileName = Constants.V1ProductDir + "custom/response_v1/complete.json")
{
return UnitTestBase.GetMindeeApi(fileName);
}
diff --git a/tests/Mindee.UnitTests/V1/MindeeClientOptionsTest.cs b/tests/Mindee.UnitTests/V1/PollingOptionsTest.cs
similarity index 90%
rename from tests/Mindee.UnitTests/V1/MindeeClientOptionsTest.cs
rename to tests/Mindee.UnitTests/V1/PollingOptionsTest.cs
index a1c7e846..2972aa89 100644
--- a/tests/Mindee.UnitTests/V1/MindeeClientOptionsTest.cs
+++ b/tests/Mindee.UnitTests/V1/PollingOptionsTest.cs
@@ -2,8 +2,9 @@
namespace Mindee.UnitTests
{
+ [Trait("Category", "V1")]
[Trait("Category", "Mindee client options")]
- public class MindeeClientOptionsTest
+ public class PollingOptionsTest
{
[Fact]
public void InvalidPollingOptions_MustFail()
diff --git a/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs b/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs
index 9822ef43..115c28ba 100644
--- a/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/BarcodeReader/BarcodeReaderV1Test.cs
@@ -19,13 +19,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/barcode_reader/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "barcode_reader/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/barcode_reader/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/barcode_reader/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/BillOfLading/BillOfLadingV1Test.cs b/tests/Mindee.UnitTests/V1/Product/BillOfLading/BillOfLadingV1Test.cs
index 5a6ebdd1..0d4272e7 100644
--- a/tests/Mindee.UnitTests/V1/Product/BillOfLading/BillOfLadingV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/BillOfLading/BillOfLadingV1Test.cs
@@ -39,13 +39,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/bill_of_lading/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "bill_of_lading/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/bill_of_lading/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/bill_of_lading/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/BusinessCard/BusinessCardV1Test.cs b/tests/Mindee.UnitTests/V1/Product/BusinessCard/BusinessCardV1Test.cs
index 9953b0f3..794f6d6b 100644
--- a/tests/Mindee.UnitTests/V1/Product/BusinessCard/BusinessCardV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/BusinessCard/BusinessCardV1Test.cs
@@ -28,13 +28,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/business_card/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "business_card/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/business_card/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/business_card/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Cropper/CropperV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Cropper/CropperV1Test.cs
index 53f92611..4ff7daa5 100644
--- a/tests/Mindee.UnitTests/V1/Product/Cropper/CropperV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Cropper/CropperV1Test.cs
@@ -18,20 +18,20 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/cropper/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "cropper/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
[Fact]
public async Task Predict_CheckPage0()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/cropper/response_v1/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "cropper/response_v1/summary_page0.rst");
Assert.Equal(expected, response.Document.Inference.Pages[0].ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/cropper/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/cropper/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Custom/CustomV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Custom/CustomV1Test.cs
index e8d93536..1e12e253 100644
--- a/tests/Mindee.UnitTests/V1/Product/Custom/CustomV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Custom/CustomV1Test.cs
@@ -11,7 +11,7 @@ public class CustomV1Test
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/custom/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "custom/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
@@ -19,7 +19,7 @@ public async Task Predict_CheckSummary()
public async Task Predict_CheckPage0()
{
var prediction = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/custom/response_v1/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "custom/response_v1/summary_page0.rst");
Assert.Equal(expected, prediction.Document.Inference.Pages[0].ToString());
}
@@ -111,7 +111,7 @@ public async Task Predict_MustSuccessfullyHandleMultiplePages()
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/custom/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/custom/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter()
diff --git a/tests/Mindee.UnitTests/V1/Product/DeliveryNote/DeliveryNoteV1Test.cs b/tests/Mindee.UnitTests/V1/Product/DeliveryNote/DeliveryNoteV1Test.cs
index 56ed4b2d..39aa4071 100644
--- a/tests/Mindee.UnitTests/V1/Product/DeliveryNote/DeliveryNoteV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/DeliveryNote/DeliveryNoteV1Test.cs
@@ -24,13 +24,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/delivery_notes/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "delivery_notes/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/delivery_notes/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/delivery_notes/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/DriverLicense/DriverLicenseV1Test.cs b/tests/Mindee.UnitTests/V1/Product/DriverLicense/DriverLicenseV1Test.cs
index 01151566..11193063 100644
--- a/tests/Mindee.UnitTests/V1/Product/DriverLicense/DriverLicenseV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/DriverLicense/DriverLicenseV1Test.cs
@@ -30,13 +30,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/driver_license/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "driver_license/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/driver_license/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/driver_license/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/FinancialDocument/FinancialDocumentV1Test.cs b/tests/Mindee.UnitTests/V1/Product/FinancialDocument/FinancialDocumentV1Test.cs
index d03504fe..450ec7f8 100644
--- a/tests/Mindee.UnitTests/V1/Product/FinancialDocument/FinancialDocumentV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/FinancialDocument/FinancialDocumentV1Test.cs
@@ -42,7 +42,7 @@ public async Task Predict_CheckEmpty()
public async Task Predict_Invoice_CheckSummary()
{
var response = await GetPrediction("complete_invoice");
- var expected = File.ReadAllText("Resources/v1/products/financial_document/response_v1/summary_full_invoice.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "financial_document/response_v1/summary_full_invoice.rst");
Assert.Equal(
expected,
response.Document.ToString());
@@ -52,7 +52,7 @@ public async Task Predict_Invoice_CheckSummary()
public async Task Predict_Invoice_FirstPage_CheckSummary()
{
var response = await GetPrediction("complete_invoice");
- var expected = File.ReadAllText("Resources/v1/products/financial_document/response_v1/summary_page0_invoice.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "financial_document/response_v1/summary_page0_invoice.rst");
Assert.Equal(
expected,
response.Document.Inference.Pages.First().ToString());
@@ -62,7 +62,7 @@ public async Task Predict_Invoice_FirstPage_CheckSummary()
public async Task Predict_Receipt_CheckSummary()
{
var response = await GetPrediction("complete_receipt");
- var expected = File.ReadAllText("Resources/v1/products/financial_document/response_v1/summary_full_receipt.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "financial_document/response_v1/summary_full_receipt.rst");
Assert.Equal(
expected,
response.Document.ToString());
@@ -72,7 +72,7 @@ public async Task Predict_Receipt_CheckSummary()
public async Task Predict_Receipt_FirstPage_CheckSummary()
{
var response = await GetPrediction("complete_receipt");
- var expected = File.ReadAllText("Resources/v1/products/financial_document/response_v1/summary_page0_receipt.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "financial_document/response_v1/summary_page0_receipt.rst");
Assert.Equal(
expected,
response.Document.Inference.Pages.First().ToString());
@@ -80,7 +80,7 @@ public async Task Predict_Receipt_FirstPage_CheckSummary()
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/financial_document/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/financial_document/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1Test.cs
index d6ca6d9a..60f80bfd 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1Test.cs
@@ -20,13 +20,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/bank_account_details/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "bank_account_details/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/bank_account_details/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/bank_account_details/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2Test.cs
index d956b1dc..b775433b 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2Test.cs
@@ -24,13 +24,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/bank_account_details/response_v2/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "bank_account_details/response_v2/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/bank_account_details/response_v2/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/bank_account_details/response_v2/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/CarteGrise/CarteGriseV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/CarteGrise/CarteGriseV1Test.cs
index da7ec197..21fbdd71 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/CarteGrise/CarteGriseV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/CarteGrise/CarteGriseV1Test.cs
@@ -58,13 +58,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/carte_grise/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "carte_grise/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/carte_grise/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/carte_grise/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/EnergyBill/EnergyBillV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/EnergyBill/EnergyBillV1Test.cs
index abb884d7..4e05fc7a 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/EnergyBill/EnergyBillV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/EnergyBill/EnergyBillV1Test.cs
@@ -35,13 +35,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/energy_bill_fra/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "energy_bill_fra/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/energy_bill_fra/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/energy_bill_fra/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/HealthCard/HealthCardV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/HealthCard/HealthCardV1Test.cs
index a6f60ce7..a898241d 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/HealthCard/HealthCardV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/HealthCard/HealthCardV1Test.cs
@@ -21,13 +21,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/french_healthcard/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "french_healthcard/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/french_healthcard/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/french_healthcard/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV1Test.cs
index 1aedfcb6..6dfcd937 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV1Test.cs
@@ -29,20 +29,20 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/idcard_fr/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "idcard_fr/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
[Fact]
public async Task Predict_CheckPage0()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/idcard_fr/response_v1/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "idcard_fr/response_v1/summary_page0.rst");
Assert.Equal(expected, response.Document.Inference.Pages[0].ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/idcard_fr/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/idcard_fr/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV2Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV2Test.cs
index a7df322f..0a0e5808 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV2Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/IdCard/IdCardV2Test.cs
@@ -35,20 +35,20 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/idcard_fr/response_v2/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "idcard_fr/response_v2/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
[Fact]
public async Task Predict_CheckPage0()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/idcard_fr/response_v2/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "idcard_fr/response_v2/summary_page0.rst");
Assert.Equal(expected, response.Document.Inference.Pages[0].ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/idcard_fr/response_v2/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/idcard_fr/response_v2/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV2Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV2Test.cs
index 60209824..1d4eabce 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV2Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV2Test.cs
@@ -59,13 +59,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/payslip_fra/response_v2/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "payslip_fra/response_v2/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/payslip_fra/response_v2/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/payslip_fra/response_v2/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV3Test.cs b/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV3Test.cs
index 95ae8235..1cfc67e7 100644
--- a/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV3Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Fr/Payslip/PayslipV3Test.cs
@@ -58,13 +58,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/payslip_fra/response_v3/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "payslip_fra/response_v3/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/payslip_fra/response_v3/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/payslip_fra/response_v3/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Generated/GeneratedV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Generated/GeneratedV1Test.cs
index 02f6dcd1..9389b74e 100644
--- a/tests/Mindee.UnitTests/V1/Product/Generated/GeneratedV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Generated/GeneratedV1Test.cs
@@ -172,7 +172,7 @@ public async Task UsMailPredict_WhenComplete_MustHaveValidBooleanField()
private static async Task> GetReceiptsItemsClassifierPrediction()
{
- string fileName = $"Resources/v1/products/receipts_items_classifier/response_v1/complete.json";
+ string fileName = Constants.V1RootDir + $"products/receipts_items_classifier/response_v1/complete.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictAsyncPostAsync(
UnitTestBase.GetFakePredictParameter()
@@ -181,7 +181,7 @@ private static async Task> GetReceiptsItemsCla
private static async Task> GetUsMailPrediction()
{
- string fileName = $"Resources/v1/products/us_mail/response_v3/complete.json";
+ string fileName = Constants.V1RootDir + $"products/us_mail/response_v3/complete.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictAsyncPostAsync(
UnitTestBase.GetFakePredictParameter()
@@ -190,7 +190,7 @@ private static async Task> GetUsMailPrediction
private static async Task> GetAsyncPrediction(string name)
{
- string fileName = $"Resources/v1/products/generated/response_v1/{name}_international_id_v1.json";
+ string fileName = Constants.V1RootDir + $"products/generated/response_v1/{name}_international_id_v1.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictAsyncPostAsync(
UnitTestBase.GetFakePredictParameter()
@@ -199,7 +199,7 @@ private static async Task> GetAsyncPrediction(
private static Task> GetSyncPrediction(string name)
{
- string fileName = $"Resources/v1/products/generated/response_v1/{name}_invoice_v4.json";
+ string fileName = Constants.V1RootDir + $"products/generated/response_v1/{name}_invoice_v4.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter()
diff --git a/tests/Mindee.UnitTests/V1/Product/Ind/IndianPassport/IndianPassportV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Ind/IndianPassport/IndianPassportV1Test.cs
index 46168757..021a3029 100644
--- a/tests/Mindee.UnitTests/V1/Product/Ind/IndianPassport/IndianPassportV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Ind/IndianPassport/IndianPassportV1Test.cs
@@ -40,13 +40,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/ind_passport/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "ind_passport/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/ind_passport/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/ind_passport/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/InternationalId/InternationalIdV2Test.cs b/tests/Mindee.UnitTests/V1/Product/InternationalId/InternationalIdV2Test.cs
index e614cb93..33a221da 100644
--- a/tests/Mindee.UnitTests/V1/Product/InternationalId/InternationalIdV2Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/InternationalId/InternationalIdV2Test.cs
@@ -34,13 +34,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/international_id/response_v2/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "international_id/response_v2/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/international_id/response_v2/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/international_id/response_v2/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Invoice/InvoiceV4Test.cs b/tests/Mindee.UnitTests/V1/Product/Invoice/InvoiceV4Test.cs
index 249534ad..b08eab22 100644
--- a/tests/Mindee.UnitTests/V1/Product/Invoice/InvoiceV4Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Invoice/InvoiceV4Test.cs
@@ -46,13 +46,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/invoices/response_v4/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "invoices/response_v4/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/invoices/response_v4/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/invoices/response_v4/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/InvoiceSplitter/InvoiceSplitterV1Test.cs b/tests/Mindee.UnitTests/V1/Product/InvoiceSplitter/InvoiceSplitterV1Test.cs
index 0d7c68ea..387ea550 100644
--- a/tests/Mindee.UnitTests/V1/Product/InvoiceSplitter/InvoiceSplitterV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/InvoiceSplitter/InvoiceSplitterV1Test.cs
@@ -18,13 +18,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/invoice_splitter/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "invoice_splitter/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/invoice_splitter/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/invoice_splitter/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1Test.cs b/tests/Mindee.UnitTests/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1Test.cs
index c9957e08..8d4d74ae 100644
--- a/tests/Mindee.UnitTests/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1Test.cs
@@ -18,13 +18,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/multi_receipts_detector/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "multi_receipts_detector/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/multi_receipts_detector/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/multi_receipts_detector/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/NutritionFactsLabel/NutritionFactsLabelV1Test.cs b/tests/Mindee.UnitTests/V1/Product/NutritionFactsLabel/NutritionFactsLabelV1Test.cs
index cf4a9e84..6047c449 100644
--- a/tests/Mindee.UnitTests/V1/Product/NutritionFactsLabel/NutritionFactsLabelV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/NutritionFactsLabel/NutritionFactsLabelV1Test.cs
@@ -55,13 +55,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/nutrition_facts/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "nutrition_facts/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/nutrition_facts/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/nutrition_facts/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Passport/PassportV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Passport/PassportV1Test.cs
index d1b46e7d..fca1274f 100644
--- a/tests/Mindee.UnitTests/V1/Product/Passport/PassportV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Passport/PassportV1Test.cs
@@ -28,13 +28,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/passport/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "passport/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/passport/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/passport/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV4Test.cs b/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV4Test.cs
index b19bb037..d7fe8f16 100644
--- a/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV4Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV4Test.cs
@@ -10,7 +10,7 @@ public class ReceiptV4Test
public async Task Predict_CheckSummary()
{
var response = await GetPrediction();
- var expected = File.ReadAllText("Resources/v1/products/expense_receipts/response_v4/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "expense_receipts/response_v4/summary_full.rst");
Assert.Equal(
expected,
response.Document.ToString());
@@ -20,7 +20,7 @@ public async Task Predict_CheckSummary()
public async Task Predict_CheckSummary_WithMultiplePages()
{
var response = await GetPrediction();
- var expected = File.ReadAllText("Resources/v1/products/expense_receipts/response_v4/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "expense_receipts/response_v4/summary_page0.rst");
Assert.Equal(
expected,
response.Document.Inference.Pages.First().ToString());
@@ -73,7 +73,7 @@ public async Task Predict_WithReceiptData_MustSuccessForOrientation()
[Fact]
public async Task Predict_WithCropping_MustSuccess()
{
- const string fileName = "Resources/v1/extras/cropper/complete.json";
+ const string fileName = Constants.V1RootDir + "extras/cropper/complete.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
var response = await mindeeAPi.PredictPostAsync(UnitTestBase.GetFakePredictParameter());
@@ -138,7 +138,7 @@ public async Task Predict_WithCropping_MustSuccess()
private static async Task> GetPrediction()
{
- const string fileName = "Resources/v1/products/expense_receipts/response_v4/complete.json";
+ const string fileName = Constants.V1ProductDir + "expense_receipts/response_v4/complete.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(UnitTestBase.GetFakePredictParameter());
}
diff --git a/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV5Test.cs b/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV5Test.cs
index ac417151..acac578a 100644
--- a/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV5Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Receipt/ReceiptV5Test.cs
@@ -34,13 +34,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/expense_receipts/response_v5/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "expense_receipts/response_v5/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/expense_receipts/response_v5/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/expense_receipts/response_v5/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Resume/ResumeV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Resume/ResumeV1Test.cs
index 899a25aa..f831f282 100644
--- a/tests/Mindee.UnitTests/V1/Product/Resume/ResumeV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Resume/ResumeV1Test.cs
@@ -34,13 +34,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/resume/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "resume/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/resume/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/resume/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs
index 99832657..00adc05a 100644
--- a/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Us/BankCheck/BankCheckV1Test.cs
@@ -27,20 +27,20 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/bank_check/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "bank_check/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
[Fact]
public async Task Predict_CheckPage0()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/bank_check/response_v1/summary_page0.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "bank_check/response_v1/summary_page0.rst");
Assert.Equal(expected, response.Document.Inference.Pages[0].ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/bank_check/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/bank_check/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Us/HealthcareCard/HealthcareCardV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/HealthcareCard/HealthcareCardV1Test.cs
index 22d79c08..37481dcb 100644
--- a/tests/Mindee.UnitTests/V1/Product/Us/HealthcareCard/HealthcareCardV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Us/HealthcareCard/HealthcareCardV1Test.cs
@@ -31,13 +31,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/us_healthcare_cards/response_v1/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "us_healthcare_cards/response_v1/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/us_healthcare_cards/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/us_healthcare_cards/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs
index 4e695a67..9ccf698c 100644
--- a/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1Test.cs
@@ -65,7 +65,7 @@ public async Task Predict_CheckPage0()
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/payroll_check_register/response_v1/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/payroll_check_register/response_v1/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.DocumentQueueGetAsync(jobId: "fake-job-id");
}
diff --git a/tests/Mindee.UnitTests/V1/Product/Us/UsMail/UsMailV3Test.cs b/tests/Mindee.UnitTests/V1/Product/Us/UsMail/UsMailV3Test.cs
index 19fb201e..6d73c9b4 100644
--- a/tests/Mindee.UnitTests/V1/Product/Us/UsMail/UsMailV3Test.cs
+++ b/tests/Mindee.UnitTests/V1/Product/Us/UsMail/UsMailV3Test.cs
@@ -26,13 +26,13 @@ public async Task Predict_CheckEmpty()
public async Task Predict_CheckSummary()
{
var response = await GetPrediction("complete");
- var expected = File.ReadAllText("Resources/v1/products/us_mail/response_v3/summary_full.rst");
+ var expected = File.ReadAllText(Constants.V1ProductDir + "us_mail/response_v3/summary_full.rst");
Assert.Equal(expected, response.Document.ToString());
}
private static async Task> GetPrediction(string name)
{
- string fileName = $"Resources/v1/products/us_mail/response_v3/{name}.json";
+ string fileName = Constants.V1RootDir + $"products/us_mail/response_v3/{name}.json";
var mindeeAPi = UnitTestBase.GetMindeeApi(fileName);
return await mindeeAPi.PredictPostAsync(
UnitTestBase.GetFakePredictParameter());
diff --git a/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs b/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs
index e1a2a040..8a8c9a06 100644
--- a/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs
+++ b/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs
@@ -28,7 +28,7 @@ protected WorklowTest()
public async Task GivenAWorkflowMockFileShouldReturnAValidWorkflowObject()
{
// Arrange
- var file = new FileInfo("src/test/resources/file_types/pdf/blank_1.pdf");
+ var file = new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf");
var workflowResponse = new WorkflowResponse { Execution = new Execution(), ApiRequest = null };
mindeeApi.Setup(api => api.PostWorkflowExecution(
@@ -52,7 +52,7 @@ public async Task GivenAWorkflowMockFileShouldReturnAValidWorkflowObject()
public async Task SendingADocumentToAnExecutionShouldDeserializeResponseCorrectly()
{
// Arrange
- var jsonFile = File.ReadAllText("src/test/resources/v1/workflows/success.json");
+ var jsonFile = File.ReadAllText(Constants.V1RootDir + "workflows/success.json");
var mockResponse = JsonSerializer.Deserialize>(jsonFile);
mockedClient.Setup(mindeeClient => mindeeClient.ExecuteWorkflowAsync(
@@ -63,7 +63,7 @@ public async Task SendingADocumentToAnExecutionShouldDeserializeResponseCorrectl
.ReturnsAsync(mockResponse);
string workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6";
- string filePath = "src/test/resources/products/financial_document/default_sample.jpg";
+ string filePath = "Resources/products/financial_document/default_sample.jpg";
var inputSource = new LocalInputSource(filePath);
// Act
@@ -98,7 +98,7 @@ public async Task SendingADocumentToAnExecutionShouldDeserializeResponseCorrectl
public async Task SendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseCorrectly()
{
// Arrange
- var jsonFile = File.ReadAllText("src/test/resources/v1/workflows/success_low_priority.json");
+ var jsonFile = File.ReadAllText(Constants.V1RootDir + "workflows/success_low_priority.json");
var mockResponse = JsonSerializer.Deserialize>(jsonFile);
mockedClient.Setup(mindeeClient => mindeeClient.ExecuteWorkflowAsync(
@@ -109,7 +109,7 @@ public async Task SendingADocumentToAnExecutionWithPriorityAndAliasShouldDeseria
.ReturnsAsync(mockResponse);
string workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6";
- string filePath = "src/test/resources/products/financial_document/default_sample.jpg";
+ string filePath = Constants.V1ProductDir + "financial_document/default_sample.jpg";
var inputSource = new LocalInputSource(filePath);
// Act
diff --git a/tests/Mindee.UnitTests/V2/MindeeClientTest.cs b/tests/Mindee.UnitTests/V2/MindeeClientTest.cs
index b07c8f28..da962850 100644
--- a/tests/Mindee.UnitTests/V2/MindeeClientTest.cs
+++ b/tests/Mindee.UnitTests/V2/MindeeClientTest.cs
@@ -7,7 +7,7 @@ namespace Mindee.UnitTests.V2
{
[Trait("Category", "V2")]
[Trait("Category", "Mindee client")]
- public class MindeeV1ClientTest
+ public class MindeeClientTest
{
private MindeeClientV2 MakeCustomMindeeClientV2(Mock predictable)
{
@@ -32,7 +32,7 @@ public async Task Enqueue_Post_Async()
var predictable = new Mock();
var mindeeClient = MakeCustomMindeeClientV2(predictable);
- var inputSource = new LocalInputSource(new FileInfo("Resources/file_types/pdf/blank_1.pdf"));
+ var inputSource = new LocalInputSource(new FileInfo(Constants.RootDir + "file_types/pdf/blank_1.pdf"));
var response = await mindeeClient.EnqueueInferenceAsync(
inputSource, new InferenceParameters("dummy-model-id"));
@@ -73,7 +73,7 @@ public async Task Document_GetJob_Async()
public void Inference_LoadsLocally()
{
var localResponse = new LocalResponse(
- new FileInfo("Resources/v2/products/financial_document/complete.json"));
+ new FileInfo(Constants.V2RootDir + "products/financial_document/complete.json"));
var locallyLoadedResponse = localResponse.DeserializeResponse();
Assert.NotNull(locallyLoadedResponse);
Assert.Equal("12345678-1234-1234-1234-123456789abc", locallyLoadedResponse.Inference.Model.Id);
diff --git a/tests/Mindee.UnitTests/V2/Parsing/InferenceV2Test.cs b/tests/Mindee.UnitTests/V2/Parsing/InferenceTest.cs
similarity index 79%
rename from tests/Mindee.UnitTests/V2/Parsing/InferenceV2Test.cs
rename to tests/Mindee.UnitTests/V2/Parsing/InferenceTest.cs
index 1f0b8388..71543dd2 100644
--- a/tests/Mindee.UnitTests/V2/Parsing/InferenceV2Test.cs
+++ b/tests/Mindee.UnitTests/V2/Parsing/InferenceTest.cs
@@ -7,12 +7,12 @@ namespace Mindee.UnitTests.V2.Parsing
{
[Trait("Category", "V2")]
[Trait("Category", "Inference")]
- public class InferenceV2Test
+ public class InferenceTest
{
[Fact]
- public void AsyncPredict_WhenEmpty_MustHaveValidProperties()
+ public void FinancialDocument_WhenEmpty_MustHaveValidProperties()
{
- var response = GetInference("Resources/v2/products/financial_document/blank.json");
+ var response = GetInference("products/financial_document/blank.json");
var fields = response.Inference.Result.Fields;
Assert.Equal(21, fields.Count);
Assert.Empty(fields["taxes"].ListField.Items);
@@ -47,9 +47,9 @@ public void AsyncPredict_WhenEmpty_MustHaveValidProperties()
}
[Fact]
- public void AsyncPredict_WhenComplete_MustHaveValidProperties()
+ public void FinancialDocument_WhenComplete_MustHaveValidProperties()
{
- var response = GetInference("Resources/v2/products/financial_document/complete.json");
+ InferenceResponse response = GetInference("products/financial_document/complete.json");
InferenceActiveOptions activeOptions = response.Inference.ActiveOptions;
Assert.NotNull(activeOptions);
Assert.False(activeOptions.Rag);
@@ -83,8 +83,8 @@ public void AsyncPredict_WhenComplete_MustHaveValidProperties()
[Fact(DisplayName = "deep_nested_fields.json – all nested structures must be typed correctly")]
public void DeepNestedFields_mustExposeCorrectTypes()
{
- var resp = GetInference("Resources/v2/inference/deep_nested_fields.json");
- Inference? inf = resp.Inference;
+ InferenceResponse response = GetInference("inference/deep_nested_fields.json");
+ Inference? inf = response.Inference;
Assert.NotNull(inf);
InferenceFields fields = inf.Result.Fields;
@@ -113,8 +113,8 @@ public void DeepNestedFields_mustExposeCorrectTypes()
[Fact(DisplayName = "standard_field_types.json – file metadata must be recognised")]
public void StandardFieldTypes_mustExposeFileValues()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inference = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inference = response.Inference;
Assert.NotNull(inference);
InferenceFile file = inference.File;
Assert.NotNull(file);
@@ -135,8 +135,8 @@ public void StandardFieldTypes_mustExposeFileValues()
[Fact(DisplayName = "standard_field_types.json – simple fields must be recognised")]
public void StandardFieldTypes_mustExposeSimpleFieldValues()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inference = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inference = response.Inference;
Assert.NotNull(inference);
InferenceFields fields = inference.Result.Fields;
@@ -175,8 +175,8 @@ public void StandardFieldTypes_mustExposeSimpleFieldValues()
[Fact(DisplayName = "standard_field_types.json – simple list fields must be recognised")]
public void StandardFieldTypes_mustExposeSimpleListFieldValues()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inference = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inference = response.Inference;
Assert.NotNull(inference);
InferenceFields fields = inference.Result.Fields;
@@ -196,8 +196,8 @@ public void StandardFieldTypes_mustExposeSimpleListFieldValues()
[Fact(DisplayName = "standard_field_types.json – object fields must be recognised")]
public void StandardFieldTypes_mustExposeObjectFieldValues()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inference = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inference = response.Inference;
Assert.NotNull(inference);
InferenceFields fields = inference.Result.Fields;
@@ -220,8 +220,8 @@ public void StandardFieldTypes_mustExposeObjectFieldValues()
[Fact(DisplayName = "standard_field_types.json – simple list fields must be recognised")]
public void StandardFieldTypes_mustExposeObjectListFieldValues()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inference = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inference = response.Inference;
Assert.NotNull(inference);
InferenceFields fields = inference.Result.Fields;
@@ -250,37 +250,11 @@ public void StandardFieldTypes_mustExposeObjectListFieldValues()
}
}
- [Fact]
- public void AsyncPredict_WhenComplete_MustHaveRawText()
- {
- InferenceResponse response = GetInference("Resources/v2/inference/raw_texts.json");
-
- InferenceActiveOptions activeOptions = response.Inference.ActiveOptions;
- Assert.NotNull(activeOptions);
- Assert.False(activeOptions.Rag);
- Assert.False(activeOptions.Polygon);
- Assert.False(activeOptions.Confidence);
- Assert.True(activeOptions.RawText);
-
- RawText rawText = response.Inference.Result.RawText;
- Assert.NotNull(rawText);
- Assert.NotNull(rawText.Pages);
- Assert.Equal(2, rawText.Pages.Count);
- foreach (RawTextPage page in rawText.Pages)
- {
- Assert.NotNull(page.Content);
- }
- Assert.Equal("This is the raw text of the first page...", rawText.Pages[0].Content);
- Assert.Equal(
- File.ReadAllText("Resources/v2/inference/raw_texts.txt"),
- rawText.ToString());
- }
-
[Fact(DisplayName = "standard_field_types.json - locations must be recognised")]
public void StandardFieldTypes_mustHaveLocations()
{
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- Inference? inf = resp.Inference;
+ InferenceResponse response = GetInference("inference/standard_field_types.json");
+ Inference? inf = response.Inference;
InferenceFields fields = inf.Result.Fields;
Assert.NotNull(inf);
SimpleField simpleField = fields["field_simple_string"].SimpleField;
@@ -300,8 +274,9 @@ public void StandardFieldTypes_mustHaveLocations()
public void RstDisplay_mustBeAccessible()
{
// Arrange
- var resp = GetInference("Resources/v2/inference/standard_field_types.json");
- var rstReference = File.ReadAllText("Resources/v2/inference/standard_field_types.rst");
+ var resp = GetInference("inference/standard_field_types.json");
+ var rstReference = File.ReadAllText(
+ Constants.V2RootDir + "inference/standard_field_types.rst");
Inference inf = resp.Inference;
@@ -311,7 +286,64 @@ public void RstDisplay_mustBeAccessible()
NormalizeLineEndings(rstReference),
NormalizeLineEndings(inf.ToString())
);
+ }
+
+ [Fact]
+ public void RawText_whenActivated_mustExposeProperties()
+ {
+ InferenceResponse response = GetInference("inference/raw_texts.json");
+ InferenceActiveOptions activeOptions = response.Inference.ActiveOptions;
+ Assert.NotNull(activeOptions);
+ Assert.False(activeOptions.Rag);
+ Assert.False(activeOptions.Polygon);
+ Assert.False(activeOptions.Confidence);
+ Assert.True(activeOptions.RawText);
+ Assert.Null(response.Inference.Result.Rag);
+
+ RawText rawText = response.Inference.Result.RawText;
+ Assert.NotNull(rawText);
+ Assert.NotNull(rawText.Pages);
+ Assert.Equal(2, rawText.Pages.Count);
+ foreach (RawTextPage page in rawText.Pages)
+ {
+ Assert.NotNull(page.Content);
+ }
+ Assert.Equal("This is the raw text of the first page...", rawText.Pages[0].Content);
+ Assert.Equal(
+ File.ReadAllText(Constants.V2RootDir + "inference/raw_texts.txt"),
+ rawText.ToString());
+ }
+
+ [Fact]
+ public void Rag_whenMatched_mustExposeProperties()
+ {
+ InferenceResponse response = GetInference("inference/rag_matched.json");
+ InferenceActiveOptions activeOptions = response.Inference.ActiveOptions;
+ Assert.NotNull(activeOptions);
+ Assert.True(activeOptions.Rag);
+ Assert.False(activeOptions.Polygon);
+ Assert.False(activeOptions.Confidence);
+ Assert.False(activeOptions.RawText);
+
+ RagMetadata rag = response.Inference.Result.Rag;
+ Assert.NotNull(rag);
+ Assert.NotEmpty(rag.RetrievedDocumentId);
+ }
+
+ [Fact]
+ public void Rag_whenNotMatched_mustExposeProperties()
+ {
+ InferenceResponse response = GetInference("inference/rag_not_matched.json");
+ InferenceActiveOptions activeOptions = response.Inference.ActiveOptions;
+ Assert.NotNull(activeOptions);
+ Assert.True(activeOptions.Rag);
+ Assert.False(activeOptions.Polygon);
+ Assert.False(activeOptions.Confidence);
+ Assert.False(activeOptions.RawText);
+ RagMetadata rag = response.Inference.Result.Rag;
+ Assert.NotNull(rag);
+ Assert.Null(rag.RetrievedDocumentId);
}
///
@@ -324,7 +356,8 @@ private static string NormalizeLineEndings(string input) =>
private static InferenceResponse GetInference(string path)
{
- var localResponse = new LocalResponse(File.ReadAllText(path));
+ LocalResponse localResponse = new LocalResponse(
+ File.ReadAllText(Constants.V2RootDir + path));
return localResponse.DeserializeResponse();
}
}
diff --git a/tests/Mindee.UnitTests/V2/Parsing/JobTest.cs b/tests/Mindee.UnitTests/V2/Parsing/JobTest.cs
new file mode 100644
index 00000000..f6ffa27e
--- /dev/null
+++ b/tests/Mindee.UnitTests/V2/Parsing/JobTest.cs
@@ -0,0 +1,60 @@
+using Mindee.Input;
+using Mindee.Parsing.Common;
+using Mindee.Parsing.V2;
+
+namespace Mindee.UnitTests.V2.Parsing
+{
+ [Trait("Category", "V2")]
+ [Trait("Category", "Job")]
+ public class JobTest
+ {
+ [Fact]
+ public void OkProcessing_MustHaveValidProperties()
+ {
+ JobResponse response = GetJob("job/ok_processing.json");
+ Assert.NotNull(response.Job);
+ Assert.Equal(2025, response.Job.CreatedAt.Year);
+ Assert.StartsWith("https", response.Job.PollingUrl);
+ Assert.Null(response.Job.ResultUrl);
+ Assert.Null(response.Job.Error);
+ }
+
+ [Fact]
+ public void OkProcessed_WebhooksOk_MustHaveValidProperties()
+ {
+ JobResponse response = GetJob("job/ok_processed_webhooks_ok.json");
+ Assert.NotNull(response.Job);
+ Assert.Equal(2026, response.Job.CreatedAt.Year);
+ Assert.StartsWith("https", response.Job.PollingUrl);
+ Assert.StartsWith("https", response.Job.ResultUrl);
+ Assert.Null(response.Job.Error);
+ Assert.NotEmpty(response.Job.Webhooks);
+ JobWebhook webhook = response.Job.Webhooks.First();
+ Assert.NotNull(webhook.Id);
+ Assert.Equal(2026, webhook.CreatedAt.Year);
+ Assert.Equal("Processed", webhook.Status);
+ Assert.Null(webhook.Error);
+ }
+
+ [Fact]
+ public void Error_422_MustHaveValidProperties()
+ {
+ JobResponse response = GetJob("job/fail_422.json");
+ Assert.NotNull(response.Job);
+ Assert.Equal(2025, response.Job.CreatedAt.Year);
+ ErrorResponse error = response.Job.Error;
+ Assert.NotNull(error);
+ Assert.Equal(422, error.Status);
+ Assert.StartsWith("422-", error.Code);
+ Assert.Single(error.Errors);
+ Assert.Contains("must be a valid", error.Errors.First().Detail);
+ }
+
+ private static JobResponse GetJob(string path)
+ {
+ LocalResponse localResponse = new LocalResponse(
+ File.ReadAllText(Constants.V2RootDir + path));
+ return localResponse.DeserializeResponse();
+ }
+ }
+}
diff --git a/tests/resources b/tests/resources
index 7d843db0..b0d725b7 160000
--- a/tests/resources
+++ b/tests/resources
@@ -1 +1 @@
-Subproject commit 7d843db01df952740d0f2d39f62fc3efb86f92bb
+Subproject commit b0d725b71784a45db611c325739320b6c192b7e5