bcquality/microsoft/knowledge/testing/table-relation-test-exclude-known-invalid-relations-via-event.bad.al
Michael Dieringer e3d9b8eb25 Fix four merge-critical issues from Jesper's 2026-09-22 review
- al-testing-review.md: the generic ExpectedError cue's asserterror
  Assert.IsTrue/IsFalse exclusion was unconditional, but the
  specialized rule it deferred to only claims the pure-inversion
  shape. A test expecting the guarded Boolean-returning call itself to
  raise fell through both routes. Narrowed the exclusion to the same
  inversion-only condition the specialized cue already uses.
- asserterror-needs-expectederror-and-code.md: the rollback-sentinel
  exception (a trailing asserterror Error(...) used purely to force a
  fixture rollback, not to verify a specific failure) previously lived
  only in skill routing prose. Encoded it directly in the article's
  Anti Pattern section so every consumer of the knowledge base sees it,
  not just this one skill.
- commit-shared-test-fixture-inside-lazy-initialize.good.al/.bad.al:
  replaced hand-rolled Item.Init()/Insert(true) with
  LibraryInventory.CreateItem, so the canonical fixture doesn't itself
  trigger use-library-codeunits-for-test-fixtures.
- table-relation-test-exclude-known-invalid-relations-via-event.good.al/
  .bad.al: declared minimal "Sample Setup"/"Sample Header" tables
  inline instead of referencing undefined symbols, matching this
  repo's own convention that every fixture is self-contained.
2026-09-22 14:35:48 +02:00

37 lines
1 KiB
AL

table 50144 "Sample Setup"
{
fields
{
field(1; "Primary Key"; Code[10]) { }
field(2; "Default Category Code"; Code[20]) { }
}
keys
{
key(PK; "Primary Key") { Clustered = true; }
}
}
table 50145 "Sample Header"
{
fields
{
field(1; "No."; Code[20]) { }
field(10; "Category Code"; Code[20]) { }
}
keys
{
key(PK; "No.") { Clustered = true; }
}
}
codeunit 50141 "Sample Table Relation Test Ext"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Table Relation Test", 'OnAfterRemoveTableRelation', '', false, false)]
local procedure ExcludeSampleFieldFromTableRelationTest(var TableRelationsMetadata: Record "Table Relations Metadata" temporary)
var
TableRelationTest: Codeunit "Table Relation Test";
begin
// Removes every relation on the whole table, not just the one known exception
TableRelationTest.RemoveTableRelation(TableRelationsMetadata, Database::"Sample Header", 0, 0, 0);
end;
}