refactor+feat(backend): ChargeableCharConfig por ProductType + Reactivate + Delete endpoints (PRC-001)
Part A — MedioId → ProductTypeId rename across all C# layers:
Domain, Application, Infrastructure, API, all test projects.
Solution was non-compilable after BD refactor (5c1675e); now compiles clean (0 errors).
Part B — PATCH /api/v1/admin/chargeable-chars/{id}/reactivate:
ReactivateChargeableCharConfigCommand/Handler, SP guard maps 50410/50411/50412
→ ChargeableCharConfigReactivationNotAllowedException(Reason) → HTTP 409.
Part C — DELETE /api/v1/admin/chargeable-chars/{id}:
DeleteChargeableCharConfigCommand/Handler, physical DELETE on SYSTEM_VERSIONED table.
KeyNotFoundException → 404 via ExceptionFilter.
Tests: +30 unit tests (TDD RED→GREEN). All 1266 unit tests pass.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using FluentAssertions;
|
||||
using SIGCM2.Domain.Pricing.Exceptions;
|
||||
|
||||
namespace SIGCM2.Application.Tests.Domain.Pricing.ChargeableChars;
|
||||
|
||||
/// <summary>
|
||||
/// PRC-001 — Unit tests for ChargeableCharConfigReactivationNotAllowedException.
|
||||
/// </summary>
|
||||
public sealed class ChargeableCharConfigReactivationNotAllowedExceptionTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("ALREADY_ACTIVE")]
|
||||
[InlineData("VIGENTE_EXISTS")]
|
||||
[InlineData("POSTERIOR_ROWS_EXIST")]
|
||||
public void Constructor_SetsIdAndReason(string reason)
|
||||
{
|
||||
var ex = new ChargeableCharConfigReactivationNotAllowedException(42L, reason);
|
||||
|
||||
ex.Id.Should().Be(42L);
|
||||
ex.Reason.Should().Be(reason);
|
||||
ex.Message.Should().Contain("42");
|
||||
ex.Message.Should().Contain(reason);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exception_IsDomainException()
|
||||
{
|
||||
var ex = new ChargeableCharConfigReactivationNotAllowedException(1L, "ALREADY_ACTIVE");
|
||||
|
||||
ex.Should().BeAssignableTo<SIGCM2.Domain.Exceptions.DomainException>();
|
||||
}
|
||||
}
|
||||
@@ -95,15 +95,15 @@ public sealed class ChargeableCharConfigTests
|
||||
entity.Category.Should().Be("Currency");
|
||||
entity.PricePerUnit.Should().Be(1.5m);
|
||||
entity.ValidFrom.Should().Be(Today);
|
||||
entity.MedioId.Should().BeNull();
|
||||
entity.ProductTypeId.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WithMedioId_SetsCorrectly()
|
||||
public void Create_WithProductTypeId_SetsCorrectly()
|
||||
{
|
||||
var entity = ChargeableCharConfig.Create(5, "$", "Currency", 2.0m, Today);
|
||||
|
||||
entity.MedioId.Should().Be(5);
|
||||
entity.ProductTypeId.Should().Be(5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -218,11 +218,11 @@ public sealed class ChargeableCharConfigTests
|
||||
{
|
||||
// Rehydrate can create entities that would fail Create (e.g., IsActive=false)
|
||||
var entity = ChargeableCharConfig.Rehydrate(
|
||||
id: 42, medioId: 5, symbol: "$", category: "Currency",
|
||||
id: 42, productTypeId: 5, symbol: "$", category: "Currency",
|
||||
price: 1.5m, validFrom: Today, validTo: Today.AddDays(30), isActive: false);
|
||||
|
||||
entity.Id.Should().Be(42);
|
||||
entity.MedioId.Should().Be(5);
|
||||
entity.ProductTypeId.Should().Be(5);
|
||||
entity.Symbol.Should().Be("$");
|
||||
entity.Category.Should().Be("Currency");
|
||||
entity.PricePerUnit.Should().Be(1.5m);
|
||||
|
||||
Reference in New Issue
Block a user