Validate AI findings against source invoice reports
This commit is contained in:
1 parent
5b697ee200
commit
6e1187cdd1
5 files changed
+196
-3
No files matched your search
@@ -0,0 +1,81 @@
|
||||
using ImportAssist.Core;
|
||||
using Xunit;
|
||||
|
||||
namespace ImportAssist.Core.Tests;
|
||||
|
||||
public sealed class InvoiceAnalysisReportValidationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(3, "INV-002", true)]
|
||||
[InlineData(99, "INV-002", false)]
|
||||
[InlineData(null, "INV-002", false)]
|
||||
[InlineData(3, "INV-999", false)]
|
||||
[InlineData(2, "INV-001", false)]
|
||||
[InlineData(3, null, false)]
|
||||
public void Validate_ChecksFindingAgainstSourceReport(
|
||||
int? lineNumber,
|
||||
string? invoiceId,
|
||||
bool expectedValid)
|
||||
{
|
||||
var analysis = CreateAnalysis(lineNumber, invoiceId);
|
||||
var report = CreateReport("INV-002");
|
||||
|
||||
var errors = InvoiceAnalysisValidator.Validate(analysis, report);
|
||||
|
||||
if (expectedValid)
|
||||
Assert.Empty(errors);
|
||||
else
|
||||
Assert.NotEmpty(errors);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" \t")]
|
||||
public void Validate_AcceptsNullForMissingSourceInvoiceId(
|
||||
string sourceInvoiceId)
|
||||
{
|
||||
var analysis = CreateAnalysis(3, null);
|
||||
var report = CreateReport(sourceInvoiceId);
|
||||
|
||||
var errors = InvoiceAnalysisValidator.Validate(analysis, report);
|
||||
|
||||
Assert.Empty(errors);
|
||||
}
|
||||
|
||||
private static InvoiceAnalysis CreateAnalysis(
|
||||
int? lineNumber,
|
||||
string? invoiceId) =>
|
||||
new(
|
||||
Summary: "Testanalyse",
|
||||
Findings:
|
||||
[
|
||||
new AnalysisFinding(
|
||||
LineNumber: lineNumber,
|
||||
InvoiceId: invoiceId,
|
||||
RuleId: "INV-002",
|
||||
Description: "Kundennummer fehlt.",
|
||||
NextCheck: "Kundennummer anhand des Belegs prüfen.",
|
||||
MissingInformation: ["Kundennummer"])
|
||||
],
|
||||
Limitations: []);
|
||||
|
||||
private static ImportReport CreateReport(string invoiceId) =>
|
||||
new(
|
||||
SourceBlob: "test.csv",
|
||||
CheckedAtUtc: DateTimeOffset.UnixEpoch,
|
||||
Status: "Completed",
|
||||
Rows:
|
||||
[
|
||||
new InvoiceCheckResult(
|
||||
LineNumber: 2,
|
||||
InvoiceId: "INV-001",
|
||||
IsValid: true,
|
||||
Errors: []),
|
||||
new InvoiceCheckResult(
|
||||
LineNumber: 3,
|
||||
InvoiceId: invoiceId,
|
||||
IsValid: false,
|
||||
Errors: ["Kundennummer fehlt."])
|
||||
],
|
||||
FileErrors: []);
|
||||
}
|
||||
Reference in new issue
Block a user