Skip to content

Commit

Permalink
Merge pull request #38 from simatic-ax/renovate/ax-sdk-2405.x
Browse files Browse the repository at this point in the history
fix: unittest
  • Loading branch information
sjuergen authored Jul 8, 2024
2 parents 039c9d4 + 6adebe9 commit bd3804d
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 197 deletions.
2 changes: 1 addition & 1 deletion apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ variables:
- "--debug"
scripts:
export-tialib: ax2tia -i bin/1500/*.lib -o "bin/$LIBRARY_DOCUMENTS_FOLDER"
import-tialib:
import-tialib:
- echo "$TIA_PORTAL_INSTALL_PATH/Siemens.Simatic.Lang.Library.Importer.exe"
- '"$TIA_PORTAL_INSTALL_PATH/Siemens.Simatic.Lang.Library.Importer.exe" -i "bin/$LIBRARY_DOCUMENTS_FOLDER" -o "$GLOBAL_LIBRARY_PATH" -u'
create-tialib:
Expand Down
97 changes: 52 additions & 45 deletions test/ParkingCounter/TestCounter.st
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
// USING Siemens.Ax.ExampleLibrary;
// USING AxUnit;
USING Siemens.Ax.ExampleLibrary;
USING AxUnit;

// NAMESPACE Siemens.Ax
NAMESPACE Siemens.Ax

// {TestFixture}
// CLASS TestCounter
// VAR
// c : Counter;
// END_VAR
// {Test}
// METHOD PUBLIC Test_CountUp_1_Time_And_Get_1
// c.CountUp();
// Assert.Equal(actual := c.GetValue(), expected := 1);
// END_METHOD
// {Test}
// METHOD PUBLIC Test_CountDown_1_Time_And_Get_Minus_1
// c.CountDown();
// Assert.Equal(actual := c.GetValue(), expected := -1);
// END_METHOD
// {Test}
// METHOD PUBLIC Test_CountUp_3_Times_And_Get_3
// c.CountUp();
// c.CountUp();
// c.CountUp();
// Assert.Equal(actual := c.GetValue(), expected := 3);
// END_METHOD
// {Test}
// METHOD PUBLIC Test_CountDown_3_Time_And_Get_Minus_3
// c.CountDown();
// c.CountDown();
// c.CountDown();
// Assert.Equal(actual := c.GetValue(), expected := -3);
// END_METHOD
// {Test}
// METHOD PUBLIC Test_SetValue_To_5_And_Get_5
// c.SetValue(5);
// Assert.Equal(actual := c.GetValue(), expected := 5);
// END_METHOD
// {Test}
// METHOD PUBLIC Test_SetValue_wit_DefaultValue_And_Get_0
// c.SetValue(5);
// c.SetValue();
// Assert.Equal(actual := c.GetValue(), expected := 0);
// END_METHOD
// END_CLASS
{TestFixture}
CLASS TestCounter
VAR
c : Counter;
cStateless : Counter;
END_VAR

// END_NAMESPACE
// This method will be called before each test method
{TestSetup}
METHOD PUBLIC MyTestSetup
c := cStateless;
END_METHOD
{Test}
METHOD PUBLIC Test_CountUp_1_Time_And_Get_1
c.CountUp();
Assert.Equal(actual := c.GetValue(), expected := 1);
END_METHOD
{Test}
METHOD PUBLIC Test_CountDown_1_Time_And_Get_Minus_1
c.CountDown();
Assert.Equal(actual := c.GetValue(), expected := -1);
END_METHOD
{Test}
METHOD PUBLIC Test_CountUp_3_Times_And_Get_3
c.CountUp();
c.CountUp();
c.CountUp();
Assert.Equal(actual := c.GetValue(), expected := 3);
END_METHOD
{Test}
METHOD PUBLIC Test_CountDown_3_Time_And_Get_Minus_3
c.CountDown();
c.CountDown();
c.CountDown();
Assert.Equal(actual := c.GetValue(), expected := -3);
END_METHOD
{Test}
METHOD PUBLIC Test_SetValue_To_5_And_Get_5
c.SetValue(5);
Assert.Equal(actual := c.GetValue(), expected := 5);
END_METHOD
{Test}
METHOD PUBLIC Test_SetValue_wit_DefaultValue_And_Get_0
c.SetValue(5);
c.SetValue();
Assert.Equal(actual := c.GetValue(), expected := 0);
END_METHOD
END_CLASS

END_NAMESPACE
152 changes: 79 additions & 73 deletions test/ParkingCounter/TestParkingCounter.st
Original file line number Diff line number Diff line change
@@ -1,76 +1,82 @@
// USING Siemens.Ax.ExampleLibrary;
// USING AxUnit;
USING Siemens.Ax.ExampleLibrary;
USING AxUnit;

// NAMESPACE Siemens.Ax
NAMESPACE Siemens.Ax

// {TestFixture}
// CLASS TestParkingCounter
// VAR
// c : ParkingCounter;
// bInside : BOOL;
// bOutside : BOOL;
// END_VAR
// METHOD Config
// c.BSensorInside := REF(bInside);
// c.BSensorOutside := REF(bOutside);
// c.Limit := 2;
// END_METHOD
// /// Sinal Sequence for 1 object entering
// METHOD Enter_1_object_signal_sequence
// THIS.Config();
// bInside := FALSE;
// bOutside := FALSE;
// c.Execute();
// bInside := FALSE;
// bOutside := TRUE;
// c.Execute();
// bInside := TRUE;
// bOutside := TRUE;
// c.Execute();
// bInside := TRUE;
// bOutside := FALSE;
// c.Execute();
// bInside := FALSE;
// bOutside := FALSE;
// c.Execute();
// END_METHOD
// /// Sinal Sequence for 1 object leaving
// METHOD Leave_1_object_signal_sequence
// THIS.Config();
// bInside := FALSE;
// bOutside := FALSE;
// c.Execute();
// bInside := TRUE;
// bOutside := FALSE;
// c.Execute();
// bInside := TRUE;
// bOutside := TRUE;
// c.Execute();
// bInside := FALSE;
// bOutside := TRUE;
// c.Execute();
// bInside := FALSE;
// bOutside := FALSE;
// c.Execute();
// END_METHOD
// {Test}
// METHOD PUBLIC Count_1_object_entering
// THIS.Enter_1_object_signal_sequence();
// Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 1);
// END_METHOD
// {Test}
// METHOD PUBLIC CheckLimit_of_to_by_entering_three_objects
// THIS.Enter_1_object_signal_sequence();
// THIS.Enter_1_object_signal_sequence();
// THIS.Enter_1_object_signal_sequence();
// Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 2);
// END_METHOD
// {Test}
// METHOD PUBLIC Remove_one_of_one_object_and_expect_0
// THIS.Enter_1_object_signal_sequence();
// THIS.Leave_1_object_signal_sequence();
// Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 0);
// END_METHOD
// END_CLASS
{TestFixture}
CLASS TestParkingCounter
VAR
c : ParkingCounter;
cStateless : ParkingCounter;
bInside : BOOL;
bOutside : BOOL;
END_VAR
// This method will be called before each test method
{TestSetup}
METHOD PUBLIC MyTestSetup
c := cStateless;
END_METHOD
METHOD Config
c.BSensorInside := REF(bInside);
c.BSensorOutside := REF(bOutside);
c.Limit := 2;
END_METHOD
/// Sinal Sequence for 1 object entering
METHOD Enter_1_object_signal_sequence
THIS.Config();
bInside := FALSE;
bOutside := FALSE;
c.Execute();
bInside := FALSE;
bOutside := TRUE;
c.Execute();
bInside := TRUE;
bOutside := TRUE;
c.Execute();
bInside := TRUE;
bOutside := FALSE;
c.Execute();
bInside := FALSE;
bOutside := FALSE;
c.Execute();
END_METHOD
/// Sinal Sequence for 1 object leaving
METHOD Leave_1_object_signal_sequence
THIS.Config();
bInside := FALSE;
bOutside := FALSE;
c.Execute();
bInside := TRUE;
bOutside := FALSE;
c.Execute();
bInside := TRUE;
bOutside := TRUE;
c.Execute();
bInside := FALSE;
bOutside := TRUE;
c.Execute();
bInside := FALSE;
bOutside := FALSE;
c.Execute();
END_METHOD
{Test}
METHOD PUBLIC Count_1_object_entering
THIS.Enter_1_object_signal_sequence();
Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 1);
END_METHOD
{Test}
METHOD PUBLIC CheckLimit_of_to_by_entering_three_objects
THIS.Enter_1_object_signal_sequence();
THIS.Enter_1_object_signal_sequence();
THIS.Enter_1_object_signal_sequence();
Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 2);
END_METHOD
{Test}
METHOD PUBLIC Remove_one_of_one_object_and_expect_0
THIS.Enter_1_object_signal_sequence();
THIS.Leave_1_object_signal_sequence();
Assert.Equal(actual := c.GetAmountOfParkedItems (), expected := 0);
END_METHOD
END_CLASS

// END_NAMESPACE
END_NAMESPACE
Loading

0 comments on commit bd3804d

Please sign in to comment.