refactor: rename namespace to FiscalFlow and upgrade to .NET 10
- Rename InvoiceMaster.* to FiscalFlow.* namespace - Upgrade from .NET 8 to .NET 10 - Update all NuGet packages to latest versions - Update C# language version to 14.0
This commit is contained in:
97
backend/tests/FiscalFlow.UnitTests/Domain/InvoiceTests.cs
Normal file
97
backend/tests/FiscalFlow.UnitTests/Domain/InvoiceTests.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using FiscalFlow.Core.Entities;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace FiscalFlow.UnitTests.Domain;
|
||||
|
||||
public class InvoiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Create_ShouldInitializeInvoiceWithCorrectValues()
|
||||
{
|
||||
var connectionId = Guid.NewGuid();
|
||||
var invoice = Invoice.Create(
|
||||
connectionId,
|
||||
"fortnox",
|
||||
"test.pdf",
|
||||
"/path/to/file",
|
||||
1024,
|
||||
"hash123");
|
||||
|
||||
invoice.ConnectionId.Should().Be(connectionId);
|
||||
invoice.Provider.Should().Be("fortnox");
|
||||
invoice.OriginalFilename.Should().Be("test.pdf");
|
||||
invoice.StoragePath.Should().Be("/path/to/file");
|
||||
invoice.FileSize.Should().Be(1024);
|
||||
invoice.FileHash.Should().Be("hash123");
|
||||
invoice.Status.Should().Be(InvoiceStatus.Uploading);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetExtractionData_ShouldUpdateExtractionFields()
|
||||
{
|
||||
var invoice = CreateTestInvoice();
|
||||
var extractionData = "{\"test\": \"data\"}";
|
||||
|
||||
invoice.SetExtractionData(
|
||||
extractionData,
|
||||
0.95m,
|
||||
"Test Supplier",
|
||||
"556677-8899",
|
||||
"INV-001",
|
||||
new DateTime(2024, 1, 15),
|
||||
new DateTime(2024, 2, 15),
|
||||
1250.00m,
|
||||
250.00m,
|
||||
25,
|
||||
"123456789",
|
||||
"123-4567",
|
||||
null,
|
||||
"SEK");
|
||||
|
||||
invoice.ExtractionData.Should().Be(extractionData);
|
||||
invoice.ExtractionConfidence.Should().Be(0.95m);
|
||||
invoice.ExtractedSupplierName.Should().Be("Test Supplier");
|
||||
invoice.ExtractedSupplierOrgNumber.Should().Be("556677-8899");
|
||||
invoice.ExtractedInvoiceNumber.Should().Be("INV-001");
|
||||
invoice.ExtractedAmountTotal.Should().Be(1250.00m);
|
||||
invoice.ExtractedAmountVat.Should().Be(250.00m);
|
||||
invoice.ExtractedVatRate.Should().Be(25);
|
||||
invoice.ExtractedOcrNumber.Should().Be("123456789");
|
||||
invoice.ExtractedBankgiro.Should().Be("123-4567");
|
||||
invoice.ExtractedCurrency.Should().Be("SEK");
|
||||
invoice.Status.Should().Be(InvoiceStatus.Preview);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetStatus_Imported_ShouldSetProcessedAt()
|
||||
{
|
||||
var invoice = CreateTestInvoice();
|
||||
|
||||
invoice.SetStatus(InvoiceStatus.Imported);
|
||||
|
||||
invoice.Status.Should().Be(InvoiceStatus.Imported);
|
||||
invoice.ProcessedAt.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetError_ShouldSetErrorFieldsAndStatus()
|
||||
{
|
||||
var invoice = CreateTestInvoice();
|
||||
|
||||
invoice.SetError("INVALID_FILE", "File format not supported");
|
||||
|
||||
invoice.ErrorCode.Should().Be("INVALID_FILE");
|
||||
invoice.ErrorMessage.Should().Be("File format not supported");
|
||||
invoice.Status.Should().Be(InvoiceStatus.Failed);
|
||||
}
|
||||
|
||||
private static Invoice CreateTestInvoice()
|
||||
{
|
||||
return Invoice.Create(
|
||||
Guid.NewGuid(),
|
||||
"fortnox",
|
||||
"test.pdf",
|
||||
"/path/to/file");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user