Skip to content

Commit

Permalink
Update ExtensionTests - add tests for interfaces, Minor Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TKapitan committed Jan 3, 2021
1 parent 817b406 commit ebeb1b6
Showing 1 changed file with 62 additions and 4 deletions.
66 changes: 62 additions & 4 deletions Test/Src/Tests/ExtensionTests.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ codeunit 79002 "C4BC Extension Tests"
C4BCExtensionCard.OpenNew();
C4BCExtensionCard."Assignable Range Code".SetValue(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01());
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Table);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC1');
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt));
C4BCExtensionCard.Subform."Object Name".SetValue('ABC1');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Table);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC2');
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 30001, StrSubstNo(BadNewIDErr, 30001, TempInt));
C4BCExtensionCard.Subform."Object Name".SetValue('ABC2');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Report);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC3');
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt));
C4BCExtensionCard.Subform."Object Name".SetValue('ABC3');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::"XML Port");
C4BCExtensionCard.Subform."Object Name".SetValue('ABC4');
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 99000, StrSubstNo(BadNewIDErr, 99000, TempInt));
C4BCExtensionCard.Subform."Object Name".SetValue('ABC4');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::"XML Port");
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Expand All @@ -74,6 +74,57 @@ codeunit 79002 "C4BC Extension Tests"
Clear(C4BCExtensionCard);
end;

[Test]
/// <summary>
/// Try to assign new object IDs on the newly created extension card as an user
/// </summary>
procedure TestAssigningNewObjectIDsForObjectTypeWithoutIDsOnTheNewlyCreatedExtensionCardAsUser()
var
C4BCObjectRangeTestLibrary: Codeunit "C4BC Object Range Test Library";
C4BCExtensionCard: TestPage "C4BC Extension Card";
TempInt: Integer;
begin
//[GIVEN] given
C4BCObjectRangeTestLibrary.InitializeAssignableRanges();
Commit();

//[THEN] then
C4BCExtensionCard.OpenNew();
C4BCExtensionCard."Assignable Range Code".SetValue(C4BCObjectRangeTestLibrary.C4BCAssignableRangeHeader_Code_01());
C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Table);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC1');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform.Previous();
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 30000, StrSubstNo(BadNewIDErr, 30000, TempInt));
C4BCExtensionCard.Subform.Next();

C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Interface);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC2');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform.Previous();
Assert.IsTrue(C4BCExtensionCard.Subform."Object ID".Value() = '', StrSubstNo(BadNewIDErr, '', C4BCExtensionCard.Subform."Object ID".Value()));
C4BCExtensionCard.Subform.Next();

C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Interface);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC3');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform.Previous();
Assert.IsTrue(C4BCExtensionCard.Subform."Object ID".Value() = '', StrSubstNo(BadNewIDErr, '', C4BCExtensionCard.Subform."Object ID".Value()));
C4BCExtensionCard.Subform.Next();

C4BCExtensionCard.Subform."Object Type".SetValue("C4BC Object Type"::Table);
C4BCExtensionCard.Subform."Object Name".SetValue('ABC4');
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Subform.Previous();
Evaluate(TempInt, C4BCExtensionCard.Subform."Object ID".Value());
Assert.IsTrue(TempInt = 30001, StrSubstNo(BadNewIDErr, 30001, TempInt));
C4BCExtensionCard.Subform.Next();
C4BCExtensionCard.Close();
Clear(C4BCExtensionCard);
end;


[Test]
/// <summary>
/// Test object name structure based on the template.
Expand Down Expand Up @@ -107,6 +158,7 @@ codeunit 79002 "C4BC Extension Tests"
C4BCExtensionObject.Validate("Object Name", 'C4BC My Object');
end;


[Test]
/// <summary>
/// Test object name when no template is defined.
Expand Down Expand Up @@ -136,6 +188,7 @@ codeunit 79002 "C4BC Extension Tests"
C4BCExtensionObject.Validate("Object Name", 'C4BC My Object');
end;


[Test]
/// <summary>
/// Test extension objects with empty names
Expand Down Expand Up @@ -163,6 +216,7 @@ codeunit 79002 "C4BC Extension Tests"
Assert.ExpectedError('must have a value');
end;


[Test]
/// <summary>
/// Test how the duplicity name control works
Expand Down Expand Up @@ -194,6 +248,7 @@ codeunit 79002 "C4BC Extension Tests"
Assert.ExpectedError('Object name with the same object type cannot be duplicit.');
end;


[Test]
/// <summary>
/// Test delete extension, whether all related records are deleted.
Expand All @@ -220,6 +275,7 @@ codeunit 79002 "C4BC Extension Tests"

end;


[Test]
/// <summary>
/// Test how the duplicity of extension ID is resolved
Expand All @@ -246,6 +302,7 @@ codeunit 79002 "C4BC Extension Tests"
HelperC4BCExtensionHeader.Validate(ID, CreateGuid());
end;


[Test]
/// <summary>
/// Test how the ID is validated when new extension is created.
Expand All @@ -267,6 +324,7 @@ codeunit 79002 "C4BC Extension Tests"
Clear(C4BCExtensionHeader);
end;


[Test]
/// <summary>
/// Try to assign new object IDs on the newly created extension card as an user
Expand Down

0 comments on commit ebeb1b6

Please sign in to comment.