bcquality/microsoft/knowledge/testing/use-generateguid-for-unique-test-fixture-values.good.al
Michael Dieringer e538664a50 Address Jesper Schulz-Wedde's review on PR #158
- use-generateguid-for-unique-test-fixture-values.md: GenerateGUID()
  is a Code[10] number-series value, not a real GUID; truncating it
  with CopyStr for a shorter field cuts off the changing digits. Point
  to GenerateRandomCode/GenerateRandomCodeWithLength/GenerateRandomXMLText
  instead, which verify uniqueness against the actual table.
- Split use-testpage-visible-enabled-to-verify-field-ui-state.md: drop
  its editability claim (the sample opens with OpenView() and asserts
  Enabled(), which verifies enabled state, not editability — Editable()
  and Enabled() are distinct TestField methods). New companion article
  use-testpage-editable-to-verify-field-editability.md covers Editable()
  with OpenEdit() specifically.
- Wire GenerateGUID/CopyStr and TestPage Visible/Enabled/Editable cues
  into al-testing-review.md, and the Item Ledger Entry/Last Shipping No.
  posting cue into al-data-modeling-review.md.

The Item Ledger Entry article itself was independently verified against
current BCApps source and needs no changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-21 22:34:40 +02:00

19 lines
926 B
AL

codeunit 50132 "Sample Customer Type Library"
{
var
LibraryUtility: Codeunit "Library - Utility";
procedure CreateCustomerType(var CustomerType: Record "Customer Type")
begin
CustomerType.Init();
// Code is shorter than GenerateGUID()'s 10 characters, so use
// GenerateRandomCode instead of truncating a GUID ourselves — it
// verifies uniqueness against the table rather than just returning
// a truncated slice of the number series.
CustomerType.Code := LibraryUtility.GenerateRandomCode(CustomerType.FieldNo(Code), Database::"Customer Type");
// Description is long enough to hold the full GenerateGUID() value
// untruncated, so no uniqueness verification is needed here.
CustomerType.Description := CopyStr(LibraryUtility.GenerateGUID(), 1, MaxStrLen(CustomerType.Description));
CustomerType.Insert(true);
end;
}