Skip to content

Commit

Permalink
0.3.0 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhar-dev authored Jun 13, 2024
1 parent c585584 commit d63fc77
Show file tree
Hide file tree
Showing 17 changed files with 1,137 additions and 16 deletions.
11 changes: 11 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v0.3.0-alpha

- Integrated deserialization errors in to deserialization feedback
- Added custom deserialization error
- Added support for mobject-collections v1.3.0
- Added support for mobject-disposable v1.1.1
- Added support for mobject-enumerable v1.2.0
- Added support for mobject-errors v0.3.0
- Added support for mobject-serialization v0.5.0
- Removed mobject-json from tests and replaced with MockJsonSeralizer

## v0.2.0-alpha

- Added support for mobject-collections v1.2.0
Expand Down
Binary file modified mobject-deserialization.library
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<Compile Include="Tests\DeserializationErrorFactory_TestSuite.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Tests\CustomDeserializationFailedError_TestSuite.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Tests\MissingKeyDeserializationError_TestSuite.TcPOU">
<SubType>Code</SubType>
</Compile>
Expand All @@ -48,6 +51,9 @@
<Compile Include="Tests\Mocks\MockError.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Tests\Mocks\MockJsonSerializer.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Tests\Mocks\MockVisitor.TcPOU">
<SubType>Code</SubType>
</Compile>
Expand All @@ -66,6 +72,10 @@
<DefaultResolution>Tc2_System, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_System</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_JsonXml">
<DefaultResolution>Tc3_JsonXml, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_JsonXml</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_Module">
<DefaultResolution>Tc3_Module, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_Module</Namespace>
Expand All @@ -76,14 +86,17 @@
</PlaceholderReference>
</ItemGroup>
<ItemGroup>
<LibraryReference Include="mobject-deserialization,0.2.0,mobject">
<LibraryReference Include="mobject-deserialization,0.3.0,mobject">
<Namespace>mobject_deserialization</Namespace>
</LibraryReference>
<LibraryReference Include="mobject-errors,0.2.0,mobject">
<LibraryReference Include="mobject-disposable,1.1.1,mobject">
<Namespace>mobject_disposable</Namespace>
</LibraryReference>
<LibraryReference Include="mobject-errors,0.3.0,mobject">
<Namespace>mobject_errors</Namespace>
</LibraryReference>
<LibraryReference Include="mobject-json,1.3.0,mobject">
<Namespace>mobject_json</Namespace>
<LibraryReference Include="mobject-serialization,0.5.0,mobject">
<Namespace>mobject_serialization</Namespace>
</LibraryReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ VAR
incorrectTypeDeserializationError_TestSuite : IncorrectTypeDeserializationError_TestSuite;
incorrectKeyTypeDeserializationError_TestSuite : IncorrectKeyTypeDeserializationError_TestSuite;
deserializationErrorFactory_TestSuite : DeserializationErrorFactory_TestSuite;
customDeserializationFailedError_TestSuite : CustomDeserializationFailedError_TestSuite;
END_VAR
]]></Declaration>
<Implementation>
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,40 @@
<POU Name="DeserializationErrorFactory_TestSuite" Id="{7b79ae16-928f-4457-901a-acc38e140e45}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK DeserializationErrorFactory_TestSuite EXTENDS TcUnit.FB_TestSuite]]></Declaration>
<Implementation>
<ST><![CDATA[TestCreateIncorrectKeyTypeError();
<ST><![CDATA[TestCreateICustomDeserializationFailedError();
TestCreateIncorrectKeyTypeError();
TestCreateIncorrectTypeError();
TestCreateMissingKeyError();
TestCreateInvalidKeyError();]]></ST>
</Implementation>
<Method Name="TestCreateICustomDeserializationFailedError" Id="{d1bb8acc-7f87-0a23-05ce-525a905e0def}">
<Declaration><![CDATA[METHOD PUBLIC TestCreateICustomDeserializationFailedError
VAR
error : CustomDeserializationFailedError('testMessage');
factory : DeserializationErrorFactory;
newError : I_Error;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TEST('TestCreateICustomDeserializationFailedError');
newError := factory.CreateCustomDeserializationFailedError('testMessage');
AssertTrue(
Condition := newError.IsSameAs(error),
Message := 'Did not produce the correct error type'
);
AssertEquals_String(
Actual := newError.Message,
Expected := error.Message,
Message := 'Did not produce error with correct message'
);
newError.Dispose();
TEST_FINISHED();]]></ST>
</Implementation>
</Method>
<Method Name="TestCreateIncorrectKeyTypeError" Id="{aadd7fdd-882e-4d73-b70b-a590bfe89472}">
<Declaration><![CDATA[METHOD PUBLIC TestCreateIncorrectKeyTypeError
VAR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TEST_FINISHED();]]></ST>
<Declaration><![CDATA[METHOD PUBLIC TestSerializeWith
VAR
error : IncorrectKeyTypeDeserializationError('testType', 'testKey');
serializer : JsonSerializer;
serializer : MockJsonSerializer;
result : T_MAXSTRING;
END_VAR]]></Declaration>
<Implementation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TEST_FINISHED();]]></ST>
<Declaration><![CDATA[METHOD PUBLIC TestSerializeWith
VAR
error : IncorrectTypeDeserializationError('testType');
serializer : JsonSerializer;
serializer : MockJsonSerializer;
result : T_MAXSTRING;
END_VAR]]></Declaration>
<Implementation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TEST_FINISHED();]]></ST>
<Declaration><![CDATA[METHOD PUBLIC TestSerializeWith
VAR
error : InvalidKeyDeserializationError;
serializer : JsonSerializer;
serializer : MockJsonSerializer;
result : T_MAXSTRING;
END_VAR]]></Declaration>
<Implementation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TEST_FINISHED();]]></ST>
<Declaration><![CDATA[METHOD PUBLIC TestSerializeWith
VAR
error : MissingKeyDeserializationError('testKey');
serializer : JsonSerializer;
serializer : MockJsonSerializer;
result : T_MAXSTRING;
END_VAR]]></Declaration>
<Implementation>
Expand Down
Loading

0 comments on commit d63fc77

Please sign in to comment.