diff --git a/apax.yml b/apax.yml index 88b132b..29eb5cb 100644 --- a/apax.yml +++ b/apax.yml @@ -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: diff --git a/test/ParkingCounter/TestCounter.st b/test/ParkingCounter/TestCounter.st index ade8626..3fe84c7 100644 --- a/test/ParkingCounter/TestCounter.st +++ b/test/ParkingCounter/TestCounter.st @@ -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 diff --git a/test/ParkingCounter/TestParkingCounter.st b/test/ParkingCounter/TestParkingCounter.st index 29b6cf4..ad4edfa 100644 --- a/test/ParkingCounter/TestParkingCounter.st +++ b/test/ParkingCounter/TestParkingCounter.st @@ -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 diff --git a/test/ParkingCounter/TestParkingCounterFB.st b/test/ParkingCounter/TestParkingCounterFB.st index 4dee39f..2b7f12e 100644 --- a/test/ParkingCounter/TestParkingCounterFB.st +++ b/test/ParkingCounter/TestParkingCounterFB.st @@ -1,82 +1,88 @@ -// USING Siemens.Ax.ExampleLibrary; -// USING AxUnit; +USING Siemens.Ax.ExampleLibrary; +USING AxUnit; -// NAMESPACE Siemens.Ax +NAMESPACE Siemens.Ax -// {TestFixture} -// CLASS TestParkingCounterFB -// VAR -// c : ParkingCounterWrapper; -// bInside : BOOL; -// bOutside : BOOL; -// END_VAR -// /// Sinal Sequence for 1 object entering -// METHOD Enter_1_object_signal_sequence + {TestFixture} + CLASS TestParkingCounterFB + VAR + c : ParkingCounterWrapper; + cStateless : ParkingCounterWrapper; + bInside : BOOL; + bOutside : BOOL; + END_VAR + // This method will be called before each test method + {TestSetup} + METHOD PUBLIC MyTestSetup + c := cStateless; + END_METHOD + /// Sinal Sequence for 1 object entering + METHOD Enter_1_object_signal_sequence -// bInside := FALSE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := FALSE; -// bOutside := TRUE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := TRUE; -// bOutside := TRUE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := TRUE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := FALSE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// END_METHOD -// /// Sinal Sequence for 1 object leaving -// METHOD Leave_1_object_signal_sequence -// bInside := FALSE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := TRUE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := TRUE; -// bOutside := TRUE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := FALSE; -// bOutside := TRUE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// bInside := FALSE; -// bOutside := FALSE; -// c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); -// END_METHOD -// {Test} -// METHOD PUBLIC Count_1_object_entering -// VAR_TEMP -// cv : DINT; -// END_VAR -// THIS.Enter_1_object_signal_sequence(); -// cv := c.countValue; -// Assert.Equal(actual := cv, expected := 1); -// END_METHOD -// {Test} -// METHOD PUBLIC CheckLimit_of_to_by_entering_three_objects -// VAR_TEMP -// cv : DINT; -// END_VAR -// THIS.Enter_1_object_signal_sequence(); -// THIS.Enter_1_object_signal_sequence(); -// THIS.Enter_1_object_signal_sequence(); -// cv := c.countValue; -// Assert.Equal(actual := cv, expected := 2); -// END_METHOD -// {Test} -// METHOD PUBLIC Remove_one_of_one_object_and_expect_0 -// VAR_TEMP -// cv : DINT; -// END_VAR -// THIS.Enter_1_object_signal_sequence(); -// THIS.Leave_1_object_signal_sequence(); -// cv := c.countValue; -// Assert.Equal(actual := cv, expected := 0); -// END_METHOD -// END_CLASS + bInside := FALSE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := FALSE; + bOutside := TRUE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := TRUE; + bOutside := TRUE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := TRUE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := FALSE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + END_METHOD + /// Sinal Sequence for 1 object leaving + METHOD Leave_1_object_signal_sequence + bInside := FALSE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := TRUE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := TRUE; + bOutside := TRUE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := FALSE; + bOutside := TRUE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + bInside := FALSE; + bOutside := FALSE; + c(BSensorOutside := bOutside, BSensorInside := bInside, Limit := 2); + END_METHOD + {Test} + METHOD PUBLIC Count_1_object_entering + VAR_TEMP + cv : DINT; + END_VAR + THIS.Enter_1_object_signal_sequence(); + cv := c.countValue; + Assert.Equal(actual := cv, expected := 1); + END_METHOD + {Test} + METHOD PUBLIC CheckLimit_of_to_by_entering_three_objects + VAR_TEMP + cv : DINT; + END_VAR + THIS.Enter_1_object_signal_sequence(); + THIS.Enter_1_object_signal_sequence(); + THIS.Enter_1_object_signal_sequence(); + cv := c.countValue; + Assert.Equal(actual := cv, expected := 2); + END_METHOD + {Test} + METHOD PUBLIC Remove_one_of_one_object_and_expect_0 + VAR_TEMP + cv : DINT; + END_VAR + THIS.Enter_1_object_signal_sequence(); + THIS.Leave_1_object_signal_sequence(); + cv := c.countValue; + Assert.Equal(actual := cv, expected := 0); + END_METHOD + END_CLASS -// END_NAMESPACE +END_NAMESPACE