MdpHandoffReceiptTests.cs 1.3 KB

123456789101112131415161718192021222324252627
  1. using Admin.NET.Plugin.AiDOP.DataPlatform.Core;
  2. using Xunit;
  3. namespace Admin.NET.Plugin.AiDOP.Tests.DataPlatform;
  4. public sealed class MdpHandoffReceiptTests
  5. {
  6. [Fact]
  7. public void EachDeliveredRowMustBeAccountedForExactlyOnce()
  8. {
  9. var batch = Guid.NewGuid();
  10. var first = Guid.NewGuid();
  11. var second = Guid.NewGuid();
  12. var events = new HashSet<Guid> { first, second };
  13. var conflict = new PurchaseQuarantine(first, "businessKey", "TARGET_ORDER_CONFLICT");
  14. var partial = new PurchaseHandoffReceipt(batch, 1, [conflict]);
  15. Assert.True(partial.Matches(batch, events));
  16. Assert.True((partial with { AcceptedCount = 2, Conflicts = [] }).Matches(batch, events));
  17. Assert.True((partial with { AcceptedCount = 0, Conflicts = [conflict, conflict with { RawEventId = second }] }).Matches(batch, events));
  18. Assert.False(partial.Matches(Guid.NewGuid(), events));
  19. Assert.False((partial with { AcceptedCount = 2 }).Matches(batch, events));
  20. Assert.False((partial with { AcceptedCount = -1 }).Matches(batch, events));
  21. Assert.False((partial with { AcceptedCount = 0, Conflicts = [conflict, conflict] }).Matches(batch, events));
  22. Assert.False((partial with { Conflicts = [conflict with { RawEventId = Guid.NewGuid() }] }).Matches(batch, events));
  23. }
  24. }