diff --git a/README.md b/README.md index a07a8a1..fe9c1b9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,37 @@ During the assertion phase, Snappy performs the following steps: This discrepancy could indicate either an unexpected change or the need to update the reference snapshot to reflect the new result 4. The validated files can the be added to [source control](#source-control-received-and-verified-files). + +## Example using `TcUnit` +``` +FUNCTION_BLOCK FB_TcUnitExample EXTENDS FB_TestSuite +VAR + hr : HRESULT; + fbTcUnitAdapter : FB_TcUnitAdapter; + + stActual : ST_DemoDataType; + {attribute 'analysis' := '-33'} + stResult : ST_VerificationResult; +END_VAR +``` +``` +TEST('Test some stuff with TcHaxx.Snappy'); + +// ARRANGE + +// ACT +stActual := F_CreateDemoData(); + +// ASSERT +hr := fbTcUnitAdapter.Verify(anyArg:= stActual); + +IF NOT PENDING(hr) THEN + TEST_FINISHED_NAMED('Test some stuff with TcHaxx.Snappy'); +END_IF; +``` + +> Find more examples in the `examples` PLC project. + ## Install Snappy consists of two parts: diff --git a/examples/examples/.snappy-verified/MyTestSuiteName.MyTestName.verified.txt b/examples/examples/.snappy-verified/MyTestSuiteName.MyTestName.verified.txt index b5bf9c9..e7b7060 100644 --- a/examples/examples/.snappy-verified/MyTestSuiteName.MyTestName.verified.txt +++ b/examples/examples/.snappy-verified/MyTestSuiteName.MyTestName.verified.txt @@ -1,7 +1,7 @@ { sString: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy, nNumber: 3735928559, - nFloat: -1.2345678, + fFloat: -1.2345678, aBuffer: [ 1, 2, @@ -16,7 +16,7 @@ 11, 12, 13, - 12, + 14, 15, 16 ] diff --git a/examples/examples/.snappy-verified/TcHaxx_Snappy.examples.PRG_TcUnit.fbTcunitExample.Test some stuff with TcHaxx.Snappy.verified.txt b/examples/examples/.snappy-verified/TcHaxx_Snappy.examples.PRG_TcUnit.fbTcunitExample.Test some stuff with TcHaxx.Snappy.verified.txt new file mode 100644 index 0000000..e7b7060 --- /dev/null +++ b/examples/examples/.snappy-verified/TcHaxx_Snappy.examples.PRG_TcUnit.fbTcunitExample.Test some stuff with TcHaxx.Snappy.verified.txt @@ -0,0 +1,23 @@ +{ + sString: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy, + nNumber: 3735928559, + fFloat: -1.2345678, + aBuffer: [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ] +} \ No newline at end of file diff --git a/examples/examples/DUTs/ST_DemoDataType.TcDUT b/examples/examples/DUTs/ST_DemoDataType.TcDUT index 4901f3c..3a299e9 100644 --- a/examples/examples/DUTs/ST_DemoDataType.TcDUT +++ b/examples/examples/DUTs/ST_DemoDataType.TcDUT @@ -5,7 +5,7 @@ STRUCT sString : STRING; nNumber : UDINT; - nFloat : REAL; + fFloat : REAL; aBuffer : ARRAY[0..15] OF BYTE; END_STRUCT END_TYPE diff --git a/examples/examples/POUs/FB_TcUnitExample.TcPOU b/examples/examples/POUs/FB_TcUnitExample.TcPOU index 16aa374..b075ecc 100644 --- a/examples/examples/POUs/FB_TcUnitExample.TcPOU +++ b/examples/examples/POUs/FB_TcUnitExample.TcPOU @@ -2,33 +2,28 @@ - diff --git a/examples/examples/POUs/FB_TcUnitWithoutSnappyExample.TcPOU b/examples/examples/POUs/FB_TcUnitWithoutSnappyExample.TcPOU new file mode 100644 index 0000000..43bdfe2 --- /dev/null +++ b/examples/examples/POUs/FB_TcUnitWithoutSnappyExample.TcPOU @@ -0,0 +1,43 @@ + + + + + + + + + \ No newline at end of file diff --git a/examples/examples/POUs/F_CreateDemoData.TcPOU b/examples/examples/POUs/F_CreateDemoData.TcPOU index 06618c3..44a1265 100644 --- a/examples/examples/POUs/F_CreateDemoData.TcPOU +++ b/examples/examples/POUs/F_CreateDemoData.TcPOU @@ -9,7 +9,7 @@ VAR END_VAR ]]> - diff --git a/examples/examples/examples.plcproj b/examples/examples/examples.plcproj index 5384767..4b1d9e4 100644 --- a/examples/examples/examples.plcproj +++ b/examples/examples/examples.plcproj @@ -38,6 +38,9 @@ Code + + Code + Code @@ -88,8 +91,8 @@ - - + + "<ProjectRoot>" {192FAD59-8248-4824-A8DE-9177C94C195A} @@ -178,14 +181,14 @@ - - - System.Boolean - System.Collections.Hashtable - {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} - System.String - - + + + System.Boolean + System.Collections.Hashtable + {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} + System.String + + \ No newline at end of file diff --git a/src/TcHaxx.Snappy/TcHaxx.Snappy.tsproj b/src/TcHaxx.Snappy/TcHaxx.Snappy.tsproj index 6845bc8..9635e2e 100644 --- a/src/TcHaxx.Snappy/TcHaxx.Snappy.tsproj +++ b/src/TcHaxx.Snappy/TcHaxx.Snappy.tsproj @@ -95,12 +95,16 @@ LIB + 0 + + + UNIT_TEST 0 - + snappy Instance {08500001-0000-0000-F000-000000000064} diff --git a/src/TcHaxx.Snappy/_Config/PLC/examples.xti b/src/TcHaxx.Snappy/_Config/PLC/examples.xti index 836fc45..6f87675 100644 --- a/src/TcHaxx.Snappy/_Config/PLC/examples.xti +++ b/src/TcHaxx.Snappy/_Config/PLC/examples.xti @@ -5,7 +5,7 @@ EXAMPLES 0 - + LIB @@ -14,7 +14,7 @@ - + examples Instance {08500001-0000-0000-F000-000000000064}