mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-08 18:31:36 +01:00
Add events knowledge domain and review leaf skill
Add a new `events` knowledge domain covering AL events & subscribers, wired into the AL review pipeline. - 3 atomic articles (+ .good.al/.bad.al samples) under microsoft/knowledge/events/: the IsHandled override pattern, thin OnBefore/OnAfter integration-event publishers, and static vs manual subscribers. - New leaf skill microsoft/skills/review/al-events-review.md sourcing the events domain. - Wired into microsoft/skills/review/al-code-review.md (sub-skills + Source + description) and README.md (leaf-skill count + domain list). AL event syntax verified against Microsoft Learn. Samples are demonstration-only (not compiled by CI). Additive change; no contract change. Part of #34. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
45c2b2f5ec
commit
54ddd8ecc2
12 changed files with 477 additions and 2 deletions
|
|
@ -0,0 +1,52 @@
|
|||
// Demonstration-only AL. Not compiled by CI; illustrates the article.
|
||||
codeunit 50228 "Item Post Pub Good Sample"
|
||||
{
|
||||
procedure PostItemLine(ItemNo: Code[20]; Qty: Decimal)
|
||||
begin
|
||||
// ... post the line ...
|
||||
OnAfterPostItemLine(ItemNo, Qty);
|
||||
end;
|
||||
|
||||
[IntegrationEvent(false, false)]
|
||||
local procedure OnAfterPostItemLine(ItemNo: Code[20]; Qty: Decimal)
|
||||
begin
|
||||
end;
|
||||
}
|
||||
|
||||
codeunit 50229 "Item Post Audit Good Sample"
|
||||
{
|
||||
// Always-on behaviour belongs in a static subscriber (the default).
|
||||
EventSubscriberInstance = StaticAutomatic;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Post Pub Good Sample", 'OnAfterPostItemLine', '', false, false)]
|
||||
local procedure LogPostedLine(ItemNo: Code[20]; Qty: Decimal)
|
||||
begin
|
||||
// Audit every posted line, unconditionally.
|
||||
end;
|
||||
}
|
||||
|
||||
codeunit 50230 "Item Post Stub Good Sample"
|
||||
{
|
||||
// Scoped/temporary behaviour belongs in a manual subscriber.
|
||||
EventSubscriberInstance = Manual;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Post Pub Good Sample", 'OnAfterPostItemLine', '', false, false)]
|
||||
local procedure CaptureForTest(ItemNo: Code[20]; Qty: Decimal)
|
||||
begin
|
||||
// Record the call so a single test can assert on it.
|
||||
end;
|
||||
}
|
||||
|
||||
codeunit 50231 "Item Post Test Good Sample"
|
||||
{
|
||||
procedure VerifyPostingRaisesEvent()
|
||||
var
|
||||
Publisher: Codeunit "Item Post Pub Good Sample";
|
||||
Stub: Codeunit "Item Post Stub Good Sample";
|
||||
begin
|
||||
// Activate the scoped subscriber only for the duration of the test.
|
||||
BindSubscription(Stub);
|
||||
Publisher.PostItemLine('1000', 5);
|
||||
UnbindSubscription(Stub);
|
||||
end;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue