diff --git a/Test/Src/Tests/AssignableRangeTests.Codeunit.al b/Test/Src/Tests/AssignableRangeTests.Codeunit.al index 161edad..0da274a 100644 --- a/Test/Src/Tests/AssignableRangeTests.Codeunit.al +++ b/Test/Src/Tests/AssignableRangeTests.Codeunit.al @@ -19,18 +19,22 @@ codeunit 79000 "C4BC Assignable Range Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); TempInt := C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table); Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt)); + TempInt := C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::"XML Port"); Assert.IsTrue(TempInt = 99000, StrSubstNo(BadNewIDErr, 99000, TempInt)); - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_02()); asserterror C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table); Assert.AssertNothingInsideFilter(); + + asserterror C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::"Table Extension"); + Assert.AssertNothingInsideFilter(); end; [Test] @@ -45,20 +49,25 @@ codeunit 79000 "C4BC Assignable Range Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); TempInt := C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table); Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt)); + TempInt := C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table, 'IGNORED_BCINSTANCE'); Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt)); - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_03()); asserterror C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table); Assert.ExpectedError('instance ID and the value must not be empty'); + TempInt := C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table, 'IGNORED_BCINSTANCE'); Assert.IsTrue(TempInt = 40000, StrSubstNo(BadNewIDErr, 40000, TempInt)); + + asserterror C4BCAssignableRangeHeader.GetNewObjectID("C4BC Object Type"::Table); + Assert.ExpectedError('instance ID and the value must not be empty'); end; [Test] @@ -72,6 +81,7 @@ codeunit 79000 "C4BC Assignable Range Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); @@ -81,9 +91,9 @@ codeunit 79000 "C4BC Assignable Range Tests" [Test] /// - /// Test behavior when the field Range per BC Instances is changed + /// Test behavior when the field Range per BC Instances is changed on ranges that are not in use /// - procedure TestChangeRangePerBCInstances() + procedure TestChangeRangePerBCInstancesThatAreNotInUse() var C4BCAssignableRangeHeader: Record "C4BC Assignable Range Header"; C4BCObjectRangeTestLibrary: Codeunit "C4BC Object Range Test Library"; @@ -93,36 +103,55 @@ codeunit 79000 "C4BC Assignable Range Tests" //[WHEN] when // No Extension Lines for Assignable Range exists + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", true); C4BCAssignableRangeHeader.Modify(true); + C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", false); C4BCAssignableRangeHeader.Modify(true); + C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); + C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", true); + C4BCAssignableRangeHeader.Modify(true); + end; + + [Test] + /// + /// Test behavior when the field Range per BC Instances is changed on ranges that are already in use + /// + procedure TestChangeRangePerBCInstancesThatAreInUse() + var + C4BCAssignableRangeHeader: Record "C4BC Assignable Range Header"; + C4BCObjectRangeTestLibrary: Codeunit "C4BC Object Range Test Library"; + begin + //[GIVEN] given + C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + //[WHEN] when C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_02()); C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", true); + C4BCAssignableRangeHeader.Modify(true); C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", false); + C4BCAssignableRangeHeader.Modify(true); + C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); asserterror C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", true); Assert.ExpectedError('due to the existing extensions'); - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_03()); asserterror C4BCAssignableRangeHeader.Validate("Ranges per BC Instance", false); Assert.ExpectedError('due to the existing extensions'); end; + [Test] /// /// Test condition when the assignable range default range could be deleted. @@ -135,34 +164,19 @@ codeunit 79000 "C4BC Assignable Range Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); + asserterror C4BCAssignableRangeHeader.Validate("Default Object Range From", C4BCAssignableRangeHeader."Default Object Range From" + 10); Assert.ExpectedError('there are extension lines with'); - - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then C4BCAssignableRangeHeader.Validate("Default Object Range From", C4BCAssignableRangeHeader."Default Object Range From" - 1); C4BCAssignableRangeHeader.Validate("Default Object Range To", C4BCAssignableRangeHeader."Default Object Range To" + 10); C4BCAssignableRangeHeader.Validate("Default Object Range To", C4BCAssignableRangeHeader."Default Object Range To" - 10); - - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then asserterror C4BCAssignableRangeHeader.Validate("Default Object Range To", C4BCAssignableRangeHeader."Default Object Range From"); Assert.ExpectedError('there are extension lines with'); - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_04()); C4BCAssignableRangeHeader.Validate("Default Object Range From", 0); C4BCAssignableRangeHeader.Validate("Default Object Range To", 0); @@ -180,29 +194,20 @@ codeunit 79000 "C4BC Assignable Range Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeLine.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01(), "C4BC Object Type"::"XML Port", 99000); asserterror C4BCAssignableRangeLine.Validate("Object Range To", C4BCAssignableRangeLine."Object Range From"); Assert.ExpectedError('there are extension lines with'); - - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then C4BCAssignableRangeLine.Validate("Object Range To", C4BCAssignableRangeLine."Object Range From" + 10); C4BCAssignableRangeLine.Validate("Object Range To", C4BCAssignableRangeLine."Object Range To" + 10); + C4BCAssignableRangeLine.Rename(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01(), "C4BC Object Type"::"XML Port", 98999); C4BCAssignableRangeLine.Rename(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01(), "C4BC Object Type"::"XML Port", 99000); asserterror C4BCAssignableRangeLine.Rename(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01(), "C4BC Object Type"::"XML Port", 99001); Assert.ExpectedError('there are extension lines with'); - //[GIVEN] given - C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); - C4BCObjectRangeTestLibrary.InitializeExtensions(); - - //[THEN] then C4BCAssignableRangeLine.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_04(), "C4BC Object Type"::Enum, 100000); C4BCAssignableRangeLine.Validate("Object Range From", 0); C4BCAssignableRangeLine.Validate("Object Range To", 0); @@ -222,6 +227,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[WHEN] when C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_05()); @@ -229,7 +235,6 @@ codeunit 79000 "C4BC Assignable Range Tests" C4BCAssignableRangeHeader.Validate("Object Name Template", ''); C4BCAssignableRangeHeader.Validate("Object Name Template", 'C4BC *'); - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_06()); asserterror C4BCAssignableRangeHeader.Validate("Object Name Template", 'C4BC *'); Assert.ExpectedError('extension lines that are different from'); @@ -249,6 +254,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[WHEN] when C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); @@ -271,6 +277,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[WHEN] when C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_05()); @@ -293,6 +300,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[WHEN] when C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[THEN] then C4BCAssignableRangeLine.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01(), "C4BC Object Type"::"XML Port", 99000); @@ -316,6 +324,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeAssignableFieldRanges(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); @@ -324,7 +333,6 @@ codeunit 79000 "C4BC Assignable Range Tests" TempInt := C4BCAssignableRangeHeader.GetNewFieldID("C4BC Object Type"::Table, 'IGNORED_BCINSTANCE'); Assert.IsTrue(TempInt = 200000, StrSubstNo(BadNewIDErr, 200000, TempInt)); - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_03()); asserterror C4BCAssignableRangeHeader.GetNewFieldID("C4BC Object Type"::Table); Assert.ExpectedError('instance ID and the value must not be empty'); @@ -345,6 +353,7 @@ codeunit 79000 "C4BC Assignable Range Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeAssignableFieldRanges(); + Commit(); //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); @@ -353,7 +362,6 @@ codeunit 79000 "C4BC Assignable Range Tests" TempInt := C4BCAssignableRangeHeader.GetNewFieldID("C4BC Object Type"::Table, 'IGNORED_BCINSTANCE'); Assert.IsTrue(TempInt = 200000, StrSubstNo(BadNewIDErr, 200000, TempInt)); - //[THEN] then C4BCAssignableRangeHeader.Get(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_02()); asserterror C4BCAssignableRangeHeader.GetNewFieldID("C4BC Object Type"::Table); Assert.ExpectedError('must have a value'); diff --git a/Test/Src/Tests/BusCentrInstTests.Codeunit.al b/Test/Src/Tests/BusCentrInstTests.Codeunit.al index d893239..e4887a0 100644 --- a/Test/Src/Tests/BusCentrInstTests.Codeunit.al +++ b/Test/Src/Tests/BusCentrInstTests.Codeunit.al @@ -12,6 +12,7 @@ codeunit 79004 "C4BC Bus. Centr. Inst. Tests" /// procedure TestDeleteBusinessCentralInstance() var + C4BCExtensionUsage: Record "C4BC Extension Usage"; C4BCBusinessCentralInstance: Record "C4BC Business Central Instance"; C4BCObjectRangeTestLibrary: Codeunit "C4BC Object Range Test Library"; begin @@ -21,6 +22,7 @@ codeunit 79004 "C4BC Bus. Centr. Inst. Tests" //[WHEN] when C4BCObjectRangeTestLibrary.SetExtensionUsage(); + Commit(); //[THEN] then C4BCBusinessCentralInstance.Get(C4BCObjectRangeTestLibrary.C4BCBusinessCentralInstance_Code_02()); @@ -28,5 +30,13 @@ codeunit 79004 "C4BC Bus. Centr. Inst. Tests" C4BCBusinessCentralInstance.Get(C4BCObjectRangeTestLibrary.C4BCBusinessCentralInstance_Code_01()); asserterror C4BCBusinessCentralInstance.Delete(true); Assert.ExpectedError('due to the existing'); + + //[WHEN] when + C4BCExtensionUsage.SetRange("Business Central Instance Code", C4BCObjectRangeTestLibrary.C4BCBusinessCentralInstance_Code_01()); + C4BCExtensionUsage.DeleteAll(false); + + //[THEN] then + C4BCBusinessCentralInstance.Get(C4BCObjectRangeTestLibrary.C4BCBusinessCentralInstance_Code_01()); + C4BCBusinessCentralInstance.Delete(true); end; } \ No newline at end of file diff --git a/Test/Src/Tests/ExtensionTests.Codeunit.al b/Test/Src/Tests/ExtensionTests.Codeunit.al index d3cef5f..a87f25b 100644 --- a/Test/Src/Tests/ExtensionTests.Codeunit.al +++ b/Test/Src/Tests/ExtensionTests.Codeunit.al @@ -18,13 +18,13 @@ codeunit 79002 "C4BC Extension Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCExtensionHeader.Init(); C4BCExtensionHeader.Validate("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); Clear(C4BCExtensionHeader); - //[THEN] then C4BCExtensionHeader.Init(); asserterror C4BCExtensionHeader.Validate("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_02()); Assert.ExpectedError('must have a value'); @@ -42,6 +42,7 @@ codeunit 79002 "C4BC Extension Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCExtensionCard.OpenNew(); @@ -89,6 +90,7 @@ codeunit 79002 "C4BC Extension Tests" //[WHEN] when C4BCObjectRangeTestLibrary.SetObjectNameTemplate(); Commit(); + C4BCExtensionObject.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCExtensionObject.FindFirst(); @@ -120,6 +122,8 @@ codeunit 79002 "C4BC Extension Tests" //[WHEN] when // No Template is set + Commit(); + C4BCExtensionObject.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCExtensionObject.FindFirst(); @@ -147,6 +151,8 @@ codeunit 79002 "C4BC Extension Tests" //[WHEN] when C4BCObjectRangeTestLibrary.SetObjectNameTemplate(); + Commit(); + C4BCExtensionObject.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCExtensionObject.SetRange("Object Type", C4BCExtensionObject."Object Type"::Table); C4BCExtensionObject.FindFirst(); @@ -201,6 +207,7 @@ codeunit 79002 "C4BC Extension Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[WHEN] when C4BCExtensionHeader.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); @@ -225,6 +232,7 @@ codeunit 79002 "C4BC Extension Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[WHEN] when C4BCExtensionHeader.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_06()); @@ -249,6 +257,7 @@ codeunit 79002 "C4BC Extension Tests" begin //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); + Commit(); //[THEN] then C4BCExtensionHeader.Init(); diff --git a/Test/Src/Tests/ExtensionUsageTests.Codeunit.al b/Test/Src/Tests/ExtensionUsageTests.Codeunit.al index 9bce7ea..6804bfe 100644 --- a/Test/Src/Tests/ExtensionUsageTests.Codeunit.al +++ b/Test/Src/Tests/ExtensionUsageTests.Codeunit.al @@ -28,6 +28,8 @@ codeunit 79001 "C4BC Extension Usage Tests" C4BCExtensionObject.FindSet(); C4BCExtensionObject.Validate("Object Name", 'C4BC My Object'); C4BCExtensionObject.Modify(true); + Commit(); + C4BCExtensionObject.Next(1); //[THEN] then @@ -51,6 +53,7 @@ codeunit 79001 "C4BC Extension Usage Tests" //[GIVEN] given C4BCObjectRangeTestLibrary.InitializeAssignableRanges(); C4BCObjectRangeTestLibrary.InitializeExtensions(); + Commit(); //[WHEN] when C4BCObjectRangeTestLibrary.SetObjectNameTemplate(); @@ -94,6 +97,8 @@ codeunit 79001 "C4BC Extension Usage Tests" //[WHEN] when C4BCObjectRangeTestLibrary.SetExtensionUsage(); + Commit(); + C4BCExtensionHeader.SetRange("Assignable Range Code", C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01()); C4BCExtensionHeader.FindFirst();