mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
Six BC-specific testing-domain knowledge articles in community/knowledge/testing/, each with .good.al/.bad.al samples: - ui-calls-require-test-handlers - tablerelation-requires-prerequisite-records - handlers-enqueue-never-assert - handlerfunctions-attribute-must-match-ui-path - asserterror-needs-expectederror-and-code - use-library-codeunits-for-test-fixtures Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
34 lines
916 B
AL
34 lines
916 B
AL
codeunit 50406 "Test Handler Match Good"
|
|
{
|
|
Subtype = Test;
|
|
|
|
[Test]
|
|
[HandlerFunctions('ConfirmHandlerYes,PostMessageHandler')]
|
|
procedure PostWithConfirmAndMessage()
|
|
begin
|
|
// The path below raises BOTH a Confirm and a Message, and the
|
|
// attribute names exactly those two handlers — no more, no less.
|
|
RunPostingThatConfirmsAndMessages();
|
|
end;
|
|
|
|
local procedure RunPostingThatConfirmsAndMessages()
|
|
begin
|
|
if Confirm('Post this document?', false) then
|
|
Message('Posting completed.');
|
|
end;
|
|
|
|
[ConfirmHandler]
|
|
procedure ConfirmHandlerYes(Question: Text; var Reply: Boolean)
|
|
begin
|
|
Reply := true;
|
|
end;
|
|
|
|
[MessageHandler]
|
|
procedure PostMessageHandler(Message: Text)
|
|
begin
|
|
LibraryVariableStorage.Enqueue(Message);
|
|
end;
|
|
|
|
var
|
|
LibraryVariableStorage: Codeunit "Library - Variable Storage";
|
|
}
|