From 597c31e5e33ffaa0054b4f16e6d210689c2bfa81 Mon Sep 17 00:00:00 2001 From: Simon Vandamme <97227477+SimonV-Skyline@users.noreply.github.com> Date: Fri, 17 May 2024 15:33:10 +0200 Subject: [PATCH] Extended unit tests + implemented fix for duplicate name check on matrixes vs array + write (#52) --- Protocol/Helpers/ParamHelper.cs | 17 +++--- .../Param/Name/CheckNameTag/CheckNameTag.cs | 27 ++++++--- .../Validate/Invalid/DuplicatedValue.xml | 57 ++++++++++++++----- .../Samples/Validate/Valid/Valid.xml | 14 +++-- 4 files changed, 82 insertions(+), 33 deletions(-) diff --git a/Protocol/Helpers/ParamHelper.cs b/Protocol/Helpers/ParamHelper.cs index f12fe1cc..83404f03 100644 --- a/Protocol/Helpers/ParamHelper.cs +++ b/Protocol/Helpers/ParamHelper.cs @@ -1180,16 +1180,19 @@ public static bool IsValidParamAssociation(IList parameters) return false; } - if (IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.Read, EnumParamType.Write) || + var param1 = parameters[0]; + var param2 = parameters[1]; + + if (IsParamsComboOfTypes(param1, param2, EnumParamType.Read, EnumParamType.Write) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.Read, EnumParamType.WriteBit) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.ReadBit, EnumParamType.Write) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.ReadBit, EnumParamType.WriteBit) || + IsParamsComboOfTypes(param1, param2, EnumParamType.Read, EnumParamType.WriteBit) || + IsParamsComboOfTypes(param1, param2, EnumParamType.ReadBit, EnumParamType.Write) || + IsParamsComboOfTypes(param1, param2, EnumParamType.ReadBit, EnumParamType.WriteBit) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.Header, EnumParamType.Write) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.Trailer, EnumParamType.Write) || + IsParamsComboOfTypes(param1, param2, EnumParamType.Header, EnumParamType.Write) || + IsParamsComboOfTypes(param1, param2, EnumParamType.Trailer, EnumParamType.Write) || - IsParamsComboOfTypes(parameters[0], parameters[1], EnumParamType.Array, EnumParamType.Write) /* Matrix */) + (param1.IsMatrix() && param2.IsMatrix() && IsParamsComboOfTypes(param1, param2, EnumParamType.Array, EnumParamType.Write))) { return true; } diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs index 66f12351..2ae427f5 100644 --- a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs @@ -46,13 +46,26 @@ public void Param_CheckNameTag_DuplicatedValue() FileName = "DuplicatedValue", ExpectedResults = new List { - Error.DuplicatedValue(null, null, null, "SameName", "100, 150, 101").WithSubResults( - Error.DuplicatedValue(null, null, null, "SameName", "100"), - Error.DuplicatedValue(null, null, null, "SameName", "150"), - Error.DuplicatedValue(null, null, null, "SameName", "101")), - Error.DuplicatedValue(null, null, null, "SameName3", "200, 201").WithSubResults( - Error.DuplicatedValue(null, null, null, "SameName3", "200"), - Error.DuplicatedValue(null, null, null, "SameName3", "201")) + Error.DuplicatedValue(null, null, null, "Duplicate_2Read", "100, 101").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_2Read", "100"), + Error.DuplicatedValue(null, null, null, "Duplicate_2Read", "101")), + + Error.DuplicatedValue(null, null, null, "Duplicate_2Write", "200, 201").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_2Write", "200"), + Error.DuplicatedValue(null, null, null, "Duplicate_2Write", "201")), + + Error.DuplicatedValue(null, null, null, "Duplicate_2Read_1Write", "300, 350, 301").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_2Read_1Write", "300"), + Error.DuplicatedValue(null, null, null, "Duplicate_2Read_1Write", "350"), + Error.DuplicatedValue(null, null, null, "Duplicate_2Read_1Write", "301")), + + Error.DuplicatedValue(null, null, null, "Duplicate_1Read_1Table", "400, 401").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_1Read_1Table", "400"), + Error.DuplicatedValue(null, null, null, "Duplicate_1Read_1Table", "401")), + + Error.DuplicatedValue(null, null, null, "Duplicate_1Write_1Table", "500, 501").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_1Write_1Table", "500"), + Error.DuplicatedValue(null, null, null, "Duplicate_1Write_1Table", "501")), } }; diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml index c1f092e6..7735b19d 100644 --- a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -1,27 +1,54 @@  - - SameName + + Duplicate_2Read + read + + + Duplicate_2Read + read + + + + Duplicate_2Write + write + + + Duplicate_2Write + write + + + + Duplicate_2Read_1Write read - - SameName + + Duplicate_2Read_1Write write - - SameName - read - - - - SameName3 - read - - - SameName3 + + Duplicate_2Read_1Write read + + + Duplicate_1Read_1Table + read + + + Duplicate_1Read_1Table + array + + + + Duplicate_1Write_1Table + write + + + Duplicate_1Write_1Table + array + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml index aeeee6d2..a72a1b7e 100644 --- a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -62,12 +62,18 @@ - ArrayWrite - array + Matrix_Write + array + + matrix + - ArrayWrite - write + Matrix_Write + write + + matrix + \ No newline at end of file