From 7511e5cb43cd25afc844ddc751f46fe15981753b Mon Sep 17 00:00:00 2001 From: mortenseifert Date: Tue, 12 Dec 2023 18:14:23 +0000 Subject: [PATCH] 'New Performance Test App (PegBoardPerformanceTest)' --- PegBoardPerformanceTest/.vscode/launch.json | 5 + PegBoardPerformanceTest/app.json | 45 ++++++ PegBoardPerformanceTest/bcptSuite.json | 54 +++++++ .../src/BCPTAdjustCostItemEntries.Codeunit.al | 21 +++ .../BCPTCalculatePlanWorksheet.Codeunit.al | 25 +++ .../src/BCPTCreatePOWithNLines.Codeunit.al | 119 ++++++++++++++ .../src/BCPTCreateSOWithNLines.Codeunit.al | 124 ++++++++++++++ .../src/BCPTCreateSQWithNLines.Codeunit.al | 118 ++++++++++++++ .../src/BCPTDetailTrialBalReport.Codeunit.al | 17 ++ .../src/BCPTMakeWebCall.Codeunit.al | 21 +++ .../src/BCPTOpenChartOfAccounts.Codeunit.al | 22 +++ .../src/BCPTOpenCustomerList.Codeunit.al | 22 +++ .../src/BCPTOpenItemList.Codeunit.al | 22 +++ .../src/BCPTOpenPurchInvoiceList.Codeunit.al | 22 +++ .../src/BCPTOpenRoleCenterSOP.Codeunit.al | 17 ++ .../src/BCPTOpenSalesInvoiceList.Codeunit.al | 22 +++ .../src/BCPTOpenVendorList.Codeunit.al | 22 +++ .../src/BCPTPostGLEntries.Codeunit.al | 142 ++++++++++++++++ .../src/BCPTPostItemJournal.Codeunit.al | 125 +++++++++++++++ .../src/BCPTPostPurchInv.Codeunit.al | 151 ++++++++++++++++++ .../src/BCPTPostSalesWithNLines.Codeunit.al | 135 ++++++++++++++++ .../src/BCPTPurchPostWithNLines.Codeunit.al | 129 +++++++++++++++ .../src/BCPTSQLPing.Codeunit.al | 20 +++ .../src/BCPTSleep1s.Codeunit.al | 9 ++ .../src/TestCodeunitsWithParams.EnumExt.al | 31 ++++ al.code-workspace | 29 ++-- 26 files changed, 1456 insertions(+), 13 deletions(-) create mode 100644 PegBoardPerformanceTest/.vscode/launch.json create mode 100644 PegBoardPerformanceTest/app.json create mode 100644 PegBoardPerformanceTest/bcptSuite.json create mode 100644 PegBoardPerformanceTest/src/BCPTAdjustCostItemEntries.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTCalculatePlanWorksheet.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTCreatePOWithNLines.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTCreateSOWithNLines.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTCreateSQWithNLines.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTDetailTrialBalReport.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTMakeWebCall.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenChartOfAccounts.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenCustomerList.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenItemList.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenPurchInvoiceList.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenRoleCenterSOP.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenSalesInvoiceList.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTOpenVendorList.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTPostGLEntries.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTPostItemJournal.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTPostPurchInv.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTPostSalesWithNLines.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTPurchPostWithNLines.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTSQLPing.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/BCPTSleep1s.Codeunit.al create mode 100644 PegBoardPerformanceTest/src/TestCodeunitsWithParams.EnumExt.al diff --git a/PegBoardPerformanceTest/.vscode/launch.json b/PegBoardPerformanceTest/.vscode/launch.json new file mode 100644 index 0000000..ac52f4e --- /dev/null +++ b/PegBoardPerformanceTest/.vscode/launch.json @@ -0,0 +1,5 @@ +{ + "version": "0.2.0", + "configurations": [ + ] +} diff --git a/PegBoardPerformanceTest/app.json b/PegBoardPerformanceTest/app.json new file mode 100644 index 0000000..8a12a8e --- /dev/null +++ b/PegBoardPerformanceTest/app.json @@ -0,0 +1,45 @@ +{ + "id": "c344963d-3020-4883-8f53-15287b285390", + "name": "PegBoardPerformanceTest", + "publisher": "Morten Seifert", + "version": "1.0.0.0", + "brief": "Performance Toolkit Samples (US)", + "description": "This extension provides tests that simulate business processes, such as creating sales orders, for the Business Central Performance Toolkit. Developers can use these to test for performance regressions during development.", + "platform": "23.0.0.0", + "application": "23.2.0.0", + "runtime": "12.0", + "logo": "", + "url": "", + "EULA": "", + "privacyStatement": "", + "help": "", + "target": "Cloud", + "screenshots": [], + "dependencies": [ + { + "id": "75f1590f-55c5-4501-ae63-bada5534e852", + "publisher": "Microsoft", + "name": "Performance Toolkit", + "version": "23.2.0.0" + } + ], + "idRanges": [ + { + "from": 50800, + "to": 50899 + } + ], + "features": [ + "TranslationFile", + "GenerateCaptions" + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "source": {}, + "build": {}, + "internalsVisibleTo": [], + "keyVaultUrls": [] +} diff --git a/PegBoardPerformanceTest/bcptSuite.json b/PegBoardPerformanceTest/bcptSuite.json new file mode 100644 index 0000000..9769bf6 --- /dev/null +++ b/PegBoardPerformanceTest/bcptSuite.json @@ -0,0 +1,54 @@ +{ + "code": "10UserTest", + "description": "10 User Test", + "durationInMinutes": 5, + "defaultMinimumUserDelayInMilliSeconds": 120, + "oneDayCorrespondsToInMinutes": 10, + "tag": "10UserTest", + "bcptSuiteLines": [ + { + "codeunitID": 50807, + "numberOfSessions": 1, + "description": "BCPT Detail Trial Bal. Report", + "minimumUserDelay": 100, + "maximumUserDelay": 1000, + "delayBetweenIterations": 10, + "delayType": "Fixed", + "runInForeground": false + }, + { + "codeunitID": 50803, + "numberOfSessions": 1, + "description": "BCPT Create PO with N Lines", + "minimumUserDelay": 100, + "maximumUserDelay": 1000, + "delayBetweenIterations": 5, + "delayType": "Fixed", + "runInForeground": false, + "parameters": "Lines=10" + }, + { + "codeunitID": 50805, + "numberOfSessions": 1, + "description": "BCPT Create SQ with N Lines", + "minimumUserDelay": 100, + "maximumUserDelay": 1000, + "delayBetweenIterations": 5, + "delayType": "Fixed", + "runInForeground": false, + "parameters": "Lines=10" + }, + { + "codeunitID": 50804, + "numberOfSessions": 1, + "description": "BCPT Create SO with N Lines", + "minimumUserDelay": 100, + "maximumUserDelay": 1000, + "delayBetweenIterations": 5, + "delayType": "Fixed", + "runInForeground": false, + "parameters": "Lines=10" + } + ] +} + diff --git a/PegBoardPerformanceTest/src/BCPTAdjustCostItemEntries.Codeunit.al b/PegBoardPerformanceTest/src/BCPTAdjustCostItemEntries.Codeunit.al new file mode 100644 index 0000000..65150fc --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTAdjustCostItemEntries.Codeunit.al @@ -0,0 +1,21 @@ +namespace System.Test.Tooling; + +using Microsoft.Inventory.Costing; + +codeunit 50823 "BCPT Adjust Cost Item Entries" +{ + trigger OnRun() + begin + AdjusCostItemEntries(); + end; + + local procedure AdjusCostItemEntries() + var + AdjustCostItemEntries: Report "Adjust Cost - Item Entries"; + begin + //Adjust and post to GL + AdjustCostItemEntries.SetPostToGL(true); + AdjustCostItemEntries.UseRequestPage(false); + AdjustCostItemEntries.Run(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTCalculatePlanWorksheet.Codeunit.al b/PegBoardPerformanceTest/src/BCPTCalculatePlanWorksheet.Codeunit.al new file mode 100644 index 0000000..d0110a6 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTCalculatePlanWorksheet.Codeunit.al @@ -0,0 +1,25 @@ +namespace System.Test.Tooling; + +using Microsoft.Manufacturing.Planning; + +codeunit 50824 "BCPT Calculate Plan Worksheet" +{ + trigger OnRun() + begin + CalculatePlan(); + end; + + local procedure CalculatePlan() + var + CalculatePlanPlanWksh: Report "Calculate Plan - Plan. Wksh."; + StartingDate: Date; + EndingDate: Date; + begin + //Start Calculate regenerative plan of the current month + StartingDate := CalcDate('<-CM>', WorkDate()); + EndingDate := CalcDate('', WorkDate()); + CalculatePlanPlanWksh.UseRequestPage(false); + CalculatePlanPlanWksh.InitializeRequest(StartingDate, EndingDate, true); + CalculatePlanPlanWksh.Run(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTCreatePOWithNLines.Codeunit.al b/PegBoardPerformanceTest/src/BCPTCreatePOWithNLines.Codeunit.al new file mode 100644 index 0000000..513c552 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTCreatePOWithNLines.Codeunit.al @@ -0,0 +1,119 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Setup; +using Microsoft.Purchases.Vendor; +using System.Tooling; + +codeunit 50803 "BCPT Create PO with N Lines" implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + begin + if not IsInitialized or true then begin + InitTest(); + IsInitialized := true; + end; + CreatePurchaseOrder(GlobalBCPTTestContext); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', Comment = '%1 = a string'; + NoOfLinesToCreate: Integer; + + + local procedure InitTest(); + var + PurchaseSetup: Record "Purchases & Payables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + PurchaseSetup.Get(); + PurchaseSetup.TestField("Order Nos."); + NoSeriesLine.SetRange("Series Code", PurchaseSetup."Order Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + local procedure CreatePurchaseOrder(var BCPTTestContext: Codeunit "BCPT Test Context") + var + Vendor: Record Vendor; + Item: Record Item; + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + i: Integer; + begin + if not Vendor.get('10000') then + Vendor.FindFirst(); + if not Item.get('70000') then + Item.FindFirst(); + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + BCPTTestContext.StartScenario('Add Order'); + PurchaseHeader.init(); + PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order; + PurchaseHeader.Insert(true); + BCPTTestContext.EndScenario('Add Order'); + BCPTTestContext.UserWait(); + BCPTTestContext.StartScenario('Enter Account No.'); + PurchaseHeader.Validate("Buy-from Vendor No.", Vendor."No."); + PurchaseHeader.Modify(true); + Commit(); + BCPTTestContext.EndScenario('Enter Account No.'); + BCPTTestContext.UserWait(); + PurchaseLine."Document Type" := PurchaseHeader."Document Type"; + PurchaseLine."Document No." := PurchaseHeader."No."; + for i := 1 to NoOfLinesToCreate do begin + PurchaseLine."Line No." += 10000; + PurchaseLine.Init(); + PurchaseLine.Validate(Type, PurchaseLine.Type::Item); + PurchaseLine.Insert(true); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Item No.'); + PurchaseLine.Validate("No.", Item."No."); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Item No.'); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Quantity'); + PurchaseLine.Validate(Quantity, 1); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Quantity'); + PurchaseLine.Modify(true); + Commit(); + BCPTTestContext.UserWait(); + end; + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTCreateSOWithNLines.Codeunit.al b/PegBoardPerformanceTest/src/BCPTCreateSOWithNLines.Codeunit.al new file mode 100644 index 0000000..8f491eb --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTCreateSOWithNLines.Codeunit.al @@ -0,0 +1,124 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Document; +using Microsoft.Sales.Setup; +using System.Tooling; + +codeunit 50804 "BCPT Create SO with N Lines" implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + begin + if not IsInitialized then begin + InitTest(); + IsInitialized := true; + end; + CreateSalesOrder(GlobalBCPTTestContext); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesToCreate: Integer; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', Comment = '%1 = a string'; + + + local procedure InitTest(); + var + SalesSetup: Record "Sales & Receivables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + SalesSetup.Get(); + SalesSetup.TestField("Order Nos."); + NoSeriesLine.SetRange("Series Code", SalesSetup."Order Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + local procedure CreateSalesOrder(var BCPTTestContext: Codeunit "BCPT Test Context") + var + Customer: Record Customer; + Item: Record Item; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + i: Integer; + begin + if not Customer.get('10000') then + Customer.FindFirst(); + if not item.get('70000') then + Item.FindSet(); + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + BCPTTestContext.StartScenario('Add Order'); + SalesHeader.Init(); + SalesHeader."Document Type" := SalesHeader."Document Type"::Order; + SalesHeader.Insert(true); + Commit(); + BCPTTestContext.EndScenario('Add Order'); + BCPTTestContext.UserWait(); + BCPTTestContext.StartScenario('Enter Account No.'); + SalesHeader.Validate("Sell-to Customer No.", Customer."No."); + SalesHeader.Modify(true); + Commit(); + BCPTTestContext.EndScenario('Enter Account No.'); + BCPTTestContext.UserWait(); + SalesLine."Document Type" := SalesHeader."Document Type"; + SalesLine."Document No." := SalesHeader."No."; + for i := 1 to NoOfLinesToCreate do begin + SalesLine."Line No." += 10000; + SalesLine.Init(); + SalesLine.Validate(Type, SalesLine.Type::Item); + SalesLine.Insert(true); + BCPTTestContext.UserWait(); + if i = 1 then + BCPTTestContext.StartScenario('Enter Line Item No.'); + SalesLine.Validate("No.", Item."No."); + if i = 1 then + BCPTTestContext.EndScenario('Enter Line Item No.'); + BCPTTestContext.UserWait(); + if i = 1 then + BCPTTestContext.StartScenario('Enter Line Quantity'); + SalesLine.Validate(Quantity, 1); + SalesLine.Modify(true); + if i = 1 then + BCPTTestContext.EndScenario('Enter Line Quantity'); + BCPTTestContext.UserWait(); + if i mod 2 = 0 then + if Item.Next() = 0 then +#pragma warning disable AA0181, AA0175 + Item.FindSet(); +#pragma warning restore AA0181, AA0175 + end; + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTCreateSQWithNLines.Codeunit.al b/PegBoardPerformanceTest/src/BCPTCreateSQWithNLines.Codeunit.al new file mode 100644 index 0000000..fc0c9ba --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTCreateSQWithNLines.Codeunit.al @@ -0,0 +1,118 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Document; +using Microsoft.Sales.Setup; +using System.Tooling; + +codeunit 50805 "BCPT Create SQ with N Lines" implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + begin + if not IsInitialized then begin + InitTest(); + IsInitialized := true; + end; + CreateSalesQuote(GlobalBCPTTestContext); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesToCreate: Integer; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', Comment = '%1 is a string'; + + local procedure InitTest(); + var + SalesSetup: Record "Sales & Receivables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + SalesSetup.Get(); + SalesSetup.TestField("Quote Nos."); + NoSeriesLine.SetRange("Series Code", SalesSetup."Quote Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + local procedure CreateSalesQuote(var BCPTTestContext: Codeunit "BCPT Test Context") + var + Customer: Record Customer; + Item: Record Item; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + i: Integer; + begin + if not Customer.get('10000') then + Customer.FindFirst(); + if not item.get('70000') then + Item.FindFirst(); + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + BCPTTestContext.StartScenario('Add Order'); + SalesHeader.init(); + SalesHeader."Document Type" := SalesHeader."Document Type"::Quote; + SalesHeader.Insert(true); + BCPTTestContext.EndScenario('Add Order'); + Commit(); + BCPTTestContext.UserWait(); + BCPTTestContext.StartScenario('Enter Account No.'); + SalesHeader.Validate("Sell-to Customer No.", Customer."No."); + SalesHeader.Modify(true); + Commit(); + BCPTTestContext.EndScenario('Enter Account No.'); + BCPTTestContext.UserWait(); + SalesLine."Document Type" := SalesHeader."Document Type"; + SalesLine."Document No." := SalesHeader."No."; + for i := 1 to NoOfLinesToCreate do begin + SalesLine."Line No." += 10000; + SalesLine.Init(); + SalesLine.Validate(Type, SalesLine.Type::Item); + SalesLine.Insert(true); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Item No.'); + SalesLine.Validate("No.", Item."No."); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Item No.'); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Quantity'); + SalesLine.Validate(Quantity, 1); + SalesLine.Modify(true); + Commit(); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Quantity'); + end; + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTDetailTrialBalReport.Codeunit.al b/PegBoardPerformanceTest/src/BCPTDetailTrialBalReport.Codeunit.al new file mode 100644 index 0000000..f110cec --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTDetailTrialBalReport.Codeunit.al @@ -0,0 +1,17 @@ +namespace System.Test.Tooling; + +using Microsoft.Finance.GeneralLedger.Reports; +using System.Utilities; + +codeunit 50807 "BCPT Detail Trial Bal. Report" +{ + trigger OnRun(); + var + DetailTrialBal: Report "Detail Trial Balance"; + TempBlob: Codeunit "Temp Blob"; + OutStr: OutStream; + begin + TempBlob.CreateOutstream(OutStr); + DetailTrialBal.SaveAs('', ReportFormat::Pdf, OutStr); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTMakeWebCall.Codeunit.al b/PegBoardPerformanceTest/src/BCPTMakeWebCall.Codeunit.al new file mode 100644 index 0000000..a55af0d --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTMakeWebCall.Codeunit.al @@ -0,0 +1,21 @@ +namespace System.Test.Tooling; + +codeunit 50808 "BCPT Make Web Call" +{ + SingleInstance = true; + + trigger OnRun(); + var + NewUrl: text; + RequestMessage: HttpRequestMessage; + ResponseMessage: HttpResponseMessage; + Client: HttpClient; + begin + NewUrl := 'https://www.microsoft.com'; + + RequestMessage.SetRequestUri(NewUrl); + RequestMessage.Method('GET'); + + Client.Send(RequestMessage, ResponseMessage); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenChartOfAccounts.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenChartOfAccounts.Codeunit.al new file mode 100644 index 0000000..adf11b0 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenChartOfAccounts.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Finance.GeneralLedger.Account; + +codeunit 50809 "BCPT Open Chart of Accounts" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenChartAccount() + var + ChartAccount: testpage "Chart of Accounts"; + begin + ChartAccount.OpenView(); + ChartAccount.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenCustomerList.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenCustomerList.Codeunit.al new file mode 100644 index 0000000..972befa --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenCustomerList.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Sales.Customer; + +codeunit 50810 "BCPT Open Customer List" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenCustomerList() + var + CustomerList: testpage "Customer List"; + begin + CustomerList.OpenView(); + CustomerList.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenItemList.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenItemList.Codeunit.al new file mode 100644 index 0000000..85bd95c --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenItemList.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Inventory.Item; + +codeunit 50811 "BCPT Open Item List" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenItemList() + var + ItemList: testpage "Item List"; + begin + ItemList.OpenView(); + ItemList.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenPurchInvoiceList.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenPurchInvoiceList.Codeunit.al new file mode 100644 index 0000000..a3a1acb --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenPurchInvoiceList.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Purchases.Document; + +codeunit 50812 "BCPT Open Purch. Invoice List" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenPurchaseInvoices() + var + PurchaseInvoices: testpage "Purchase Invoices"; + begin + PurchaseInvoices.OpenView(); + PurchaseInvoices.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenRoleCenterSOP.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenRoleCenterSOP.Codeunit.al new file mode 100644 index 0000000..4f0181a --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenRoleCenterSOP.Codeunit.al @@ -0,0 +1,17 @@ +namespace System.Test.Tooling; + +using Microsoft.Sales.RoleCenters; + +codeunit 50813 "BCPT Open RoleCenter SOP" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + var + SOPRC: testpage "SO Processor Activities"; + begin + SOPRC.OpenView(); + SOPRC.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenSalesInvoiceList.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenSalesInvoiceList.Codeunit.al new file mode 100644 index 0000000..a94a393 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenSalesInvoiceList.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Sales.Document; + +codeunit 50814 "BCPT Open Sales Invoice List" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenSalesInvoiceList() + var + SalesInvoiceList: testpage "Sales Invoice List"; + begin + SalesInvoiceList.OpenView(); + SalesInvoiceList.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTOpenVendorList.Codeunit.al b/PegBoardPerformanceTest/src/BCPTOpenVendorList.Codeunit.al new file mode 100644 index 0000000..4da17e8 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTOpenVendorList.Codeunit.al @@ -0,0 +1,22 @@ +namespace System.Test.Tooling; + +using Microsoft.Purchases.Vendor; + +codeunit 50815 "BCPT Open Vendor List" +{ + // Test codeunits can only run in foreground (UI) + Subtype = Test; + + trigger OnRun(); + begin + end; + + [Test] + procedure OpenVendorList() + var + VendorList: testpage "Vendor List"; + begin + VendorList.OpenView(); + VendorList.Close(); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTPostGLEntries.Codeunit.al b/PegBoardPerformanceTest/src/BCPTPostGLEntries.Codeunit.al new file mode 100644 index 0000000..d0f4c5e --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTPostGLEntries.Codeunit.al @@ -0,0 +1,142 @@ +namespace System.Test.Tooling; + +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Finance.GeneralLedger.Journal; +using Microsoft.Finance.GeneralLedger.Posting; +using Microsoft.Foundation.NoSeries; +using System.Tooling; + +codeunit 50821 "BCPT Post G/L Entries" +{ + SingleInstance = true; + + trigger OnRun(); + var + begin + PostGeneralJournal(); + end; + + procedure PostGeneralJournal() + var + GenJournalLine: Record "Gen. Journal Line"; + BCPTTestContext: Codeunit "BCPT Test Context"; + begin + // Setup: Create General Journal + BCPTTestContext.StartScenario('Create General Journal Line'); + CreateGeneralJournalLine(GenJournalLine); + BCPTTestContext.EndScenario('Create General Journal Line'); + + // Exercise: Post General Journal. + BCPTTestContext.StartScenario('Post General Journal Lines'); + PostGeneralJournalLine(GenJournalLine."Journal Template Name", GenJournalLine."Journal Batch Name"); + BCPTTestContext.EndScenario('Post General Journal Lines'); + end; + + local procedure CreateGeneralJournalLine(var GenJournalLine: Record "Gen. Journal Line") + var + GenJournalBatch: Record "Gen. Journal Batch"; + begin + SelectGeneralJournal(GenJournalBatch); + + CreateGeneralJournalLine( + GenJournalLine, GenJournalBatch."Journal Template Name", + GenJournalBatch.Name); + end; + + procedure CreateGeneralJournalLine(var GenJournalLine: Record "Gen. Journal Line"; JournalTemplateName: Code[10]; JournalBatchName: Code[10]) + var + GenJournalBatch: Record "Gen. Journal Batch"; + begin + if not GenJournalBatch.Get(JournalTemplateName, JournalBatchName) then begin + GenJournalBatch.Init(); + GenJournalBatch.Validate("Journal Template Name", JournalTemplateName); + GenJournalBatch.SetupNewBatch(); + GenJournalBatch.Validate(Name, JournalBatchName); + GenJournalBatch.Validate(Description, JournalBatchName + ' journal'); + GenJournalBatch.Insert(true); + end; + CreateGeneralJnlLine(GenJournalLine, GenJournalBatch, JournalTemplateName, JournalBatchName); + end; + + procedure CreateGeneralJnlLine(var GenJournalLine: Record "Gen. Journal Line"; GenJournalBatch: Record "Gen. Journal Batch"; JournalTemplateName: Code[10]; JournalBatchName: Code[10]) + var + NoSeries: Record "No. Series"; + NoSeriesManagement: Codeunit NoSeriesManagement; + DocumentNo: Code[20]; + begin + Clear(GenJournalLine); + GenJournalLine.DeleteAll(); + //Debit amount + GenJournalLine.Init(); + GenJournalLine.Validate("Journal Template Name", JournalTemplateName); + GenJournalLine.Validate("Journal Batch Name", JournalBatchName); + GenJournalLine.Validate("Line No.", 10000); + GenJournalLine.Insert(true); + GenJournalLine.Validate("Posting Date", WorkDate()); + if NoSeries.Get(GenJournalBatch."No. Series") then + DocumentNo := NoSeriesManagement.GetNextNo(GenJournalBatch."No. Series", GenJournalLine."Posting Date", false); + GenJournalLine.Validate("Document No.", DocumentNo); + GenJournalLine.Validate("Account Type", GenJournalLine."Account Type"::"G/L Account"); + GenJournalLine.Validate("Account No.", SelectRandomGLAccount()); + GenJournalLine.Validate("Debit Amount", 1000); + GenJournalLine.Modify(true); + + //Credit amount + GenJournalLine.Init(); + GenJournalLine.Validate("Journal Template Name", JournalTemplateName); + GenJournalLine.Validate("Journal Batch Name", JournalBatchName); + GenJournalLine.Validate("Line No.", 20000); + GenJournalLine.Insert(true); + GenJournalLine.Validate("Posting Date", WorkDate()); + GenJournalLine.Validate("Document No.", DocumentNo); + GenJournalLine.Validate("Account Type", GenJournalLine."Account Type"::"G/L Account"); + GenJournalLine.Validate("Account No.", SelectRandomGLAccount()); + GenJournalLine.Validate("Credit Amount", 1000); + GenJournalLine.Modify(true); + end; + + local procedure SelectGeneralJournal(var GenJournalBatch: Record "Gen. Journal Batch") + var + GenJournalTemplate: Record "Gen. Journal Template"; + begin + SelectGeneralJournalTemplateName(GenJournalTemplate, GenJournalTemplate.Type::General); + SelectGeneralJournalBatchName(GenJournalBatch, GenJournalTemplate.Type::General, GenJournalTemplate.Name); + end; + + local procedure PostGeneralJournalLine(JournalTemplateName: Text[10]; JournalBatchName: Text[10]) + var + GenJournalLine: Record "Gen. Journal Line"; + begin + GenJournalLine.Init(); + GenJournalLine.Validate("Journal Template Name", JournalTemplateName); + GenJournalLine.Validate("Journal Batch Name", JournalBatchName); + CODEUNIT.Run(CODEUNIT::"Gen. Jnl.-Post", GenJournalLine); + end; + + local procedure SelectGeneralJournalTemplateName(var GenJournalTemplate: Record "Gen. Journal Template"; GenJournalTemplateType: Enum "Gen. Journal Template Type") + begin + // Find General Journal Template for the given Template Type. + GenJournalTemplate.SetRange(Type, GenJournalTemplateType); + GenJournalTemplate.SetRange(Recurring, false); + if GenJournalTemplate.FindFirst() then; + end; + + local procedure SelectGeneralJournalBatchName(var GenJournalBatch: Record "Gen. Journal Batch"; GenJournalTemplateType: Enum "Gen. Journal Template Type"; GenJournalTemplateName: Code[10]) + begin + // Find Name for Batch Name. + GenJournalBatch.SetRange("Template Type", GenJournalTemplateType); + GenJournalBatch.SetRange("Journal Template Name", GenJournalTemplateName); + if GenJournalBatch.FindFirst() then; + end; + + local procedure SelectRandomGLAccount(): Code[20] + var + GLAccount: Record "G/L Account"; + begin + GLAccount.SetRange("Account Type", GLAccount."Account Type"::Posting); + GLAccount.SetRange("Direct Posting", true); + GLAccount.SetFilter("Gen. Bus. Posting Group", '<>%1', ''); + GLAccount.Next(SessionId() mod GLAccount.Count()); + exit(GLAccount."No."); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTPostItemJournal.Codeunit.al b/PegBoardPerformanceTest/src/BCPTPostItemJournal.Codeunit.al new file mode 100644 index 0000000..516505a --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTPostItemJournal.Codeunit.al @@ -0,0 +1,125 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Inventory.Journal; +using Microsoft.Inventory.Ledger; +using Microsoft.Inventory.Posting; + +codeunit 50820 "BCPT Post Item Journal" +{ + SingleInstance = true; + + trigger OnRun(); + var + begin + PostItemJournal(); + end; + + procedure PostItemJournal() + var + ItemJournalLine: Record "Item Journal Line"; + begin + // Setup: Create Item Journal with Entry Type Positive Adjustment. + CreateItemJournal(ItemJournalLine); + + // Exercise: Post Item Journal. + PostItemJournalLine(ItemJournalLine."Journal Template Name", ItemJournalLine."Journal Batch Name"); + end; + + local procedure CreateItemJournal(var ItemJournalLine: Record "Item Journal Line") + var + Item: Record Item; + begin + if not Item.get('70000') then + Item.FindFirst(); + + CreateItemJournalLine(ItemJournalLine, Item."No."); + end; + + local procedure CreateItemJournalLine(var ItemJournalLine: Record "Item Journal Line"; ItemNo: Code[20]) + var + ItemJournalBatch: Record "Item Journal Batch"; + begin + SelectItemJournal(ItemJournalBatch); + CreateItemJournalLine( + ItemJournalLine, ItemJournalBatch."Journal Template Name", + ItemJournalBatch.Name, ItemJournalLine."Entry Type"::"Positive Adjmt.", ItemNo, 10); + end; + + procedure CreateItemJournalLine(var ItemJournalLine: Record "Item Journal Line"; JournalTemplateName: Code[10]; JournalBatchName: Code[10]; EntryType: Enum "Item Ledger Entry Type"; ItemNo: Text[20]; NewQuantity: Decimal) + var + ItemJournalBatch: Record "Item Journal Batch"; + begin + if not ItemJournalBatch.Get(JournalTemplateName, JournalBatchName) then begin + ItemJournalBatch.Init(); + ItemJournalBatch.Validate("Journal Template Name", JournalTemplateName); + ItemJournalBatch.SetupNewBatch(); + ItemJournalBatch.Validate(Name, JournalBatchName); + ItemJournalBatch.Validate(Description, JournalBatchName + ' journal'); + ItemJournalBatch.Insert(true); + end; + CreateItemJnlLineWithNoItem(ItemJournalLine, ItemJournalBatch, JournalTemplateName, JournalBatchName, EntryType); + ItemJournalLine.Validate("Item No.", ItemNo); + ItemJournalLine.Validate(Quantity, NewQuantity); + ItemJournalLine.Modify(true); + end; + + procedure CreateItemJnlLineWithNoItem(var ItemJournalLine: Record "Item Journal Line"; ItemJournalBatch: Record "Item Journal Batch"; JournalTemplateName: Code[10]; JournalBatchName: Code[10]; EntryType: Enum "Item Ledger Entry Type") + var + NoSeries: Record "No. Series"; + NoSeriesManagement: Codeunit NoSeriesManagement; + RecRef: RecordRef; + DocumentNo: Code[20]; + begin + Clear(ItemJournalLine); + ItemJournalLine.Init(); + ItemJournalLine.Validate("Journal Template Name", JournalTemplateName); + ItemJournalLine.Validate("Journal Batch Name", JournalBatchName); + RecRef.GetTable(ItemJournalLine); + ItemJournalLine.Validate("Line No.", 10000); + ItemJournalLine.Insert(true); + ItemJournalLine.Validate("Posting Date", WorkDate()); + ItemJournalLine.Validate("Entry Type", EntryType); + if NoSeries.Get(ItemJournalBatch."No. Series") then + DocumentNo := NoSeriesManagement.GetNextNo(ItemJournalBatch."No. Series", ItemJournalLine."Posting Date", false); + ItemJournalLine.Validate("Document No.", DocumentNo); + ItemJournalLine.Modify(true); + end; + + local procedure SelectItemJournal(var ItemJournalBatch: Record "Item Journal Batch") + var + ItemJournalTemplate: Record "Item Journal Template"; + begin + SelectItemJournalTemplateName(ItemJournalTemplate, ItemJournalTemplate.Type::Item); + SelectItemJournalBatchName(ItemJournalBatch, ItemJournalTemplate.Type::Item, ItemJournalTemplate.Name); + end; + + procedure PostItemJournalLine(JournalTemplateName: Text[10]; JournalBatchName: Text[10]) + var + ItemJournalLine: Record "Item Journal Line"; + begin + ItemJournalLine.Init(); + ItemJournalLine.Validate("Journal Template Name", JournalTemplateName); + ItemJournalLine.Validate("Journal Batch Name", JournalBatchName); + CODEUNIT.Run(CODEUNIT::"Item Jnl.-Post Batch", ItemJournalLine); + end; + + procedure SelectItemJournalTemplateName(var ItemJournalTemplate: Record "Item Journal Template"; ItemJournalTemplateType: Enum "Item Journal Template Type") + begin + // Find Item Journal Template for the given Template Type. + ItemJournalTemplate.SetRange(Type, ItemJournalTemplateType); + ItemJournalTemplate.SetRange(Recurring, false); + if ItemJournalTemplate.FindFirst() then; + end; + + procedure SelectItemJournalBatchName(var ItemJournalBatch: Record "Item Journal Batch"; ItemJournalBatchTemplateType: Enum "Item Journal Template Type"; ItemJournalTemplateName: Code[10]) + begin + // Find Name for Batch Name. + ItemJournalBatch.SetRange("Template Type", ItemJournalBatchTemplateType); + ItemJournalBatch.SetRange("Journal Template Name", ItemJournalTemplateName); + + // If Item Journal Batch not found then create it. + if ItemJournalBatch.FindFirst() then; + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTPostPurchInv.Codeunit.al b/PegBoardPerformanceTest/src/BCPTPostPurchInv.Codeunit.al new file mode 100644 index 0000000..0752051 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTPostPurchInv.Codeunit.al @@ -0,0 +1,151 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Posting; +using Microsoft.Purchases.Setup; +using Microsoft.Purchases.Vendor; +using System.Tooling; + +codeunit 50822 "BCPT Post Purch. Inv." implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + var + begin + if not IsInitialized or true then begin + InitTest(); + IsInitialized := true; + end; + + CreateAndPostPurchaseInvoice(); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', comment = '%1 = Parameter name'; + NoOfLinesToCreate: Integer; + + local procedure InitTest(); + var + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + PurchasesPayablesSetup.Get(); + PurchasesPayablesSetup.TestField("Invoice Nos."); + PurchasesPayablesSetup."Ext. Doc. No. Mandatory" := false; + PurchasesPayablesSetup.Modify(); + + NoSeriesLine.SetRange("Series Code", PurchasesPayablesSetup."Invoice Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + procedure CreateAndPostPurchaseInvoice() + var + PurchaseHeader: Record "Purchase Header"; + VendorNo: Code[20]; + begin + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + + //Find a random vendor + VendorNo := SelectRandomVendor(); + + GlobalBCPTTestContext.StartScenario('Create Purchase Invoice'); + CreatePurchaseInvoiceForVendorNo(PurchaseHeader, VendorNo); + GlobalBCPTTestContext.EndScenario('Create Purchase Invoice'); + + GlobalBCPTTestContext.StartScenario('Post Purchase Invoice'); + CODEUNIT.Run(CODEUNIT::"Purch.-Post (Yes/No)", PurchaseHeader); + GlobalBCPTTestContext.EndScenario('Post Purchase Invoice'); + end; + + local procedure SelectRandomVendor(): Code[20] + var + Vendor: Record Vendor; + begin + Vendor.SetRange(Blocked, Vendor.Blocked::" "); + Vendor.Next(SessionId() mod Vendor.Count()); + exit(Vendor."No."); + end; + + local procedure CreatePurchaseInvoiceForVendorNo(var PurchaseHeader: Record "Purchase Header"; VendorNo: Code[20]) + var + PurchaseLine: Record "Purchase Line"; + i: Integer; + LineNo: Integer; + begin + CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendorNo); + LineNo := 1000; + for i := 1 to NoOfLinesToCreate do begin + CreatePurchaseLine(PurchaseLine, PurchaseHeader, LineNo); + LineNo := LineNo + 1000; + end; + end; + + procedure CreatePurchHeader(var PurchaseHeader: Record "Purchase Header"; DocumentType: Enum "Purchase Document Type"; BuyfromVendorNo: Code[20]) + begin + Clear(PurchaseHeader); + PurchaseHeader.Validate("Document Type", DocumentType); + PurchaseHeader.Insert(true); + PurchaseHeader.Validate("Buy-from Vendor No.", BuyfromVendorNo); + PurchaseHeader.Modify(true); + Commit(); + end; + + local procedure CreatePurchaseLine(var PurchaseLine: Record "Purchase Line"; PurchaseHeader: Record "Purchase Header"; LineNo: Integer) + begin + PurchaseLine.Init(); + PurchaseLine.Validate("Document Type", PurchaseHeader."Document Type"); + PurchaseLine.Validate("Document No.", PurchaseHeader."No."); + PurchaseLine.Validate("Line No.", LineNo); + PurchaseLine.Insert(true); + Commit(); + + PurchaseLine.Validate(Type, PurchaseLine.Type::Item); + PurchaseLine.Validate("No.", SelectRandomItem()); + PurchaseLine.Validate(Quantity, 1); + PurchaseLine.Modify(true); + Commit(); + end; + + local procedure SelectRandomItem(): Code[20] + var + Item: Record Item; + begin + Item.SetRange(Blocked, false); + Item.Next(SessionId() mod Item.Count()); + exit(Item."No."); + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTPostSalesWithNLines.Codeunit.al b/PegBoardPerformanceTest/src/BCPTPostSalesWithNLines.Codeunit.al new file mode 100644 index 0000000..17ab8ea --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTPostSalesWithNLines.Codeunit.al @@ -0,0 +1,135 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Sales.Document; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Posting; +using Microsoft.Sales.Setup; +using System.Tooling; + +codeunit 50818 "BCPT Post Sales with N Lines" implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + var + SalesHeader: Record "Sales Header"; + SalesPost: Codeunit "Sales-Post"; + SalesHeaderId: Guid; + begin + if not IsInitialized then begin + InitTest(); + IsInitialized := true; + end; + SalesHeaderId := CreateSalesOrder(GlobalBCPTTestContext); + SalesHeader.GetBySystemId(SalesHeaderId); + SalesHeader.Validate(Ship, true); + SalesHeader.Validate(Invoice, true); + SalesPost.Run(SalesHeader); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesToCreate: Integer; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', Comment = '%1 is a string'; + + + local procedure InitTest(); + var + SalesSetup: Record "Sales & Receivables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + SalesSetup.Get(); + SalesSetup.TestField("Order Nos."); + NoSeriesLine.SetRange("Series Code", SalesSetup."Order Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + local procedure CreateSalesOrder(var BCPTTestContext: Codeunit "BCPT Test Context"): Guid + var + Customer: Record Customer; + Item: Record Item; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + i: Integer; + begin + if not Customer.get('10000') then + Customer.FindFirst(); + if not item.get('70000') then + Item.FindSet(); + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + BCPTTestContext.StartScenario('Add Order'); + SalesHeader.Init(); + SalesHeader."Document Type" := SalesHeader."Document Type"::Order; + SalesHeader.Insert(true); + Commit(); + BCPTTestContext.EndScenario('Add Order'); + BCPTTestContext.UserWait(); + BCPTTestContext.StartScenario('Enter Account No.'); + SalesHeader.Validate("Sell-to Customer No.", Customer."No."); + SalesHeader.Modify(true); + Commit(); + BCPTTestContext.EndScenario('Enter Account No.'); + BCPTTestContext.UserWait(); + SalesLine."Document Type" := SalesHeader."Document Type"; + SalesLine."Document No." := SalesHeader."No."; + for i := 1 to NoOfLinesToCreate do begin + SalesLine."Line No." += 10000; + SalesLine.Init(); + SalesLine.Validate(Type, SalesLine.Type::Item); + SalesLine.Insert(true); + BCPTTestContext.UserWait(); + if i = 1 then + BCPTTestContext.StartScenario('Enter Line Item No.'); + SalesLine.Validate("No.", Item."No."); + if i = 1 then + BCPTTestContext.EndScenario('Enter Line Item No.'); + BCPTTestContext.UserWait(); + if i = 1 then + BCPTTestContext.StartScenario('Enter Line Quantity'); + SalesLine.Validate(Quantity, 1); + SalesLine.Modify(true); + if i = 1 then + BCPTTestContext.EndScenario('Enter Line Quantity'); + BCPTTestContext.UserWait(); + if i mod 2 = 0 then + if Item.Next() = 0 then +#pragma warning disable AA0181, AA0175 + Item.FindSet(); +#pragma warning restore AA0181, AA0175 + end; + + exit(SalesHeader.SystemId); + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTPurchPostWithNLines.Codeunit.al b/PegBoardPerformanceTest/src/BCPTPurchPostWithNLines.Codeunit.al new file mode 100644 index 0000000..5030bba --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTPurchPostWithNLines.Codeunit.al @@ -0,0 +1,129 @@ +namespace System.Test.Tooling; + +using Microsoft.Foundation.NoSeries; +using Microsoft.Inventory.Item; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Posting; +using Microsoft.Purchases.Setup; +using Microsoft.Purchases.Vendor; +using System.Tooling; + +codeunit 50819 "BCPT Purch. Post with N Lines" implements "BCPT Test Param. Provider" +{ + SingleInstance = true; + + trigger OnRun(); + var + PurchHeader: Record "Purchase Header"; + PurchPost: Codeunit "Purch.-Post"; + PurchHeaderId: Guid; + begin + if not IsInitialized or true then begin + InitTest(); + IsInitialized := true; + end; + PurchHeaderId := CreatePurchaseOrder(GlobalBCPTTestContext); + PurchHeader.GetBySystemId(PurchHeaderId); + PurchHeader.Validate(Receive, true); + PurchHeader.Validate(Invoice, true); + PurchHeader.Validate("Vendor Invoice No.", PurchHeader."No."); + PurchPost.Run(PurchHeader); + end; + + var + GlobalBCPTTestContext: Codeunit "BCPT Test Context"; + IsInitialized: Boolean; + NoOfLinesParamLbl: Label 'Lines'; + ParamValidationErr: Label 'Parameter is not defined in the correct format. The expected format is "%1"', Comment = '%1 = a string'; + NoOfLinesToCreate: Integer; + + local procedure InitTest(); + var + PurchaseSetup: Record "Purchases & Payables Setup"; + NoSeriesLine: Record "No. Series Line"; + begin + PurchaseSetup.Get(); + PurchaseSetup.TestField("Order Nos."); + NoSeriesLine.SetRange("Series Code", PurchaseSetup."Order Nos."); + NoSeriesLine.FindSet(true); + repeat + if NoSeriesLine."Ending No." <> '' then begin + NoSeriesLine."Ending No." := ''; + NoSeriesLine.Validate("Allow Gaps in Nos.", true); + NoSeriesLine.Modify(true); + end; + until NoSeriesLine.Next() = 0; + commit(); + + if Evaluate(NoOfLinesToCreate, GlobalBCPTTestContext.GetParameter(NoOfLinesParamLbl)) then; + end; + + local procedure CreatePurchaseOrder(var BCPTTestContext: Codeunit "BCPT Test Context"): Guid + var + Vendor: Record Vendor; + Item: Record Item; + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + i: Integer; + begin + if not Vendor.get('10000') then + Vendor.FindFirst(); + if not Item.get('70000') then + Item.FindFirst(); + if NoOfLinesToCreate < 0 then + NoOfLinesToCreate := 0; + if NoOfLinesToCreate > 10000 then + NoOfLinesToCreate := 10000; + BCPTTestContext.StartScenario('Add Order'); + PurchaseHeader.init(); + PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order; + PurchaseHeader.Insert(true); + BCPTTestContext.EndScenario('Add Order'); + BCPTTestContext.UserWait(); + BCPTTestContext.StartScenario('Enter Account No.'); + PurchaseHeader.Validate("Buy-from Vendor No.", Vendor."No."); + PurchaseHeader.Modify(true); + Commit(); + BCPTTestContext.EndScenario('Enter Account No.'); + BCPTTestContext.UserWait(); + PurchaseLine."Document Type" := PurchaseHeader."Document Type"; + PurchaseLine."Document No." := PurchaseHeader."No."; + for i := 1 to NoOfLinesToCreate do begin + PurchaseLine."Line No." += 10000; + PurchaseLine.Init(); + PurchaseLine.Validate(Type, PurchaseLine.Type::Item); + PurchaseLine.Insert(true); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Item No.'); + PurchaseLine.Validate("No.", Item."No."); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Item No.'); + BCPTTestContext.UserWait(); + if i = 10 then + BCPTTestContext.StartScenario('Enter Line Quantity'); + PurchaseLine.Validate(Quantity, 1); + if i = 10 then + BCPTTestContext.EndScenario('Enter Line Quantity'); + PurchaseLine.Modify(true); + Commit(); + BCPTTestContext.UserWait(); + end; + exit(PurchaseHeader.SystemId); + end; + + procedure GetDefaultParameters(): Text[1000] + begin + exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000)); + end; + + procedure ValidateParameters(Parameters: Text[1000]) + begin + if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin + Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '=')); + if Evaluate(NoOfLinesToCreate, Parameters) then + exit; + end; + Error(ParamValidationErr, GetDefaultParameters()); + end; +} diff --git a/PegBoardPerformanceTest/src/BCPTSQLPing.Codeunit.al b/PegBoardPerformanceTest/src/BCPTSQLPing.Codeunit.al new file mode 100644 index 0000000..8656cb7 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTSQLPing.Codeunit.al @@ -0,0 +1,20 @@ +namespace System.Test.Tooling; + +using Microsoft.Finance.GeneralLedger.Setup; + +codeunit 50817 "BCPT SQL Ping" +{ + trigger OnRun(); + var + i: Integer; + begin + SelectLatestVersion(); // bypass the NST cache + for i := 1 to 100 do begin + SelectLatestVersion(); // bypass the NST cache + GLsetup.Get(); + end; + end; + + var + GLsetup: Record "General Ledger Setup"; +} diff --git a/PegBoardPerformanceTest/src/BCPTSleep1s.Codeunit.al b/PegBoardPerformanceTest/src/BCPTSleep1s.Codeunit.al new file mode 100644 index 0000000..9da00e1 --- /dev/null +++ b/PegBoardPerformanceTest/src/BCPTSleep1s.Codeunit.al @@ -0,0 +1,9 @@ +namespace System.Test.Tooling; + +codeunit 50816 "BCPT Sleep 1s" +{ + trigger OnRun(); + begin + Sleep(1000); + end; +} diff --git a/PegBoardPerformanceTest/src/TestCodeunitsWithParams.EnumExt.al b/PegBoardPerformanceTest/src/TestCodeunitsWithParams.EnumExt.al new file mode 100644 index 0000000..7cc17a6 --- /dev/null +++ b/PegBoardPerformanceTest/src/TestCodeunitsWithParams.EnumExt.al @@ -0,0 +1,31 @@ +namespace System.Test.Tooling; + +using System.Tooling; + +enumextension 50800 "Test Codeunits with Params" extends "BCPT Test Param. Enum" +{ + value(50803; "50803") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Create PO with N Lines"; + } + value(50804; "50804") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Create SO with N Lines"; + } + value(50805; "50805") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Create SQ with N Lines"; + } + value(50818; "50818") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Post Sales with N Lines"; + } + value(50819; "50819") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Purch. Post with N Lines"; + } + value(50822; "50822") + { + Implementation = "BCPT Test Param. Provider" = "BCPT Post Purch. Inv."; + } +} diff --git a/al.code-workspace b/al.code-workspace index 68bc215..5f956e0 100644 --- a/al.code-workspace +++ b/al.code-workspace @@ -1,14 +1,17 @@ { - "folders": [ - { - "path": ".AL-Go" - }, - { - "path": "Peg Board" - }, - { - "path": "Peg Board Test" - } - ], - "settings": {} -} \ No newline at end of file + "folders": [ + { + "path": ".AL-Go" + }, + { + "path": "Peg Board" + }, + { + "path": "Peg Board Test" + }, + { + "path": "PegBoardPerformanceTest" + } + ], + "settings": {} +}