-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c585584
commit d63fc77
Showing
17 changed files
with
1,137 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...-deserialization-test-project/Main/Tests/CustomDeserializationFailedError_TestSuite.TcPOU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12"> | ||
<POU Name="CustomDeserializationFailedError_TestSuite" Id="{fa0d09c9-b154-0b31-0a63-257a16fa47df}" SpecialFunc="None"> | ||
<Declaration><![CDATA[FUNCTION_BLOCK CustomDeserializationFailedError_TestSuite EXTENDS TcUnit.FB_TestSuite]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TestAccept(); | ||
TestErrorType(); | ||
TestIsSameAsWithSameErrors(); | ||
TestIsSameAsWithDifferentErrors(); | ||
TestMessage(); | ||
TestSerializeWith();]]></ST> | ||
</Implementation> | ||
<Method Name="TestAccept" Id="{b82ebc90-7911-05cc-1974-29186f172e66}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestAccept | ||
VAR | ||
error : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
visitor : MockVisitor(ExpectedError := error); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestAccept'); | ||
error.Accept(visitor); | ||
AssertTrue( | ||
Condition := visitor.VisitedCorrectError, | ||
Message := 'Did not invoke VisitError on the visitor' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="TestErrorType" Id="{feb45d11-c836-03b1-1eb8-a468b3e8b683}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestErrorType | ||
VAR | ||
error : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestErrorType'); | ||
AssertEquals_String( | ||
Actual := error.ErrorType, | ||
Expected := 'CUSTOM_DESERIALIZATION_ERROR', | ||
Message := 'Did not return the expected ErrorType' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="TestIsSameAsWithDifferentErrors" Id="{67b4b579-c80d-0e65-250d-db0104d15a79}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestIsSameAsWithDifferentErrors | ||
VAR | ||
error1 : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
error2 : MockError(MockErrorType:='ERROR_TYPE_B',MockMessage:='TestMessage'); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestIsSameAsWithDifferentErrors'); | ||
AssertFalse( | ||
Condition := error1.IsSameAs(error2), | ||
Message := 'Did not correctly identify errors as being different type' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="TestIsSameAsWithSameErrors" Id="{65009b05-0dc3-01fb-0713-2406322c93ad}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestIsSameAsWithSameErrors | ||
VAR | ||
error1 : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
error2 : MockError(MockErrorType:='CUSTOM_DESERIALIZATION_ERROR',MockMessage:='Deserialization Failed, TestMessage'); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestIsSameAsWithSameErrors'); | ||
AssertTrue( | ||
Condition := error1.IsSameAs(error2), | ||
Message := 'Did not correctly identify errors as being the same type' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="TestMessage" Id="{03270791-0cbe-07e1-254f-726467faf9f2}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestMessage | ||
VAR | ||
error : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestMessage'); | ||
AssertEquals_String( | ||
Actual := error.Message, | ||
Expected := 'Deserialization Failed, TestMessage', | ||
Message := 'Did not return the expected Message' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
<Method Name="TestSerializeWith" Id="{b0b825b2-943a-002a-2947-89fd7501af3a}"> | ||
<Declaration><![CDATA[METHOD PUBLIC TestSerializeWith | ||
VAR | ||
error : CustomDeserializationFailedError(Message := 'TestMessage'); | ||
serializer : MockJsonSerializer; | ||
result : T_MAXSTRING; | ||
END_VAR]]></Declaration> | ||
<Implementation> | ||
<ST><![CDATA[TEST('TestSerializeWith'); | ||
error.SerializeWith(serializer); | ||
serializer.TryGetSerializedData(ADR(result), SIZEOF(result)); | ||
AssertEquals_String( | ||
Actual := result, | ||
Expected := '{"errorType":"CUSTOM_DESERIALIZATION_ERROR","message":"Deserialization Failed, TestMessage"}', | ||
Message := 'Did not serialize correctly' | ||
); | ||
TEST_FINISHED();]]></ST> | ||
</Implementation> | ||
</Method> | ||
</POU> | ||
</TcPlcObject> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.