Skip to content

Commit

Permalink
Extended unit tests + implemented fix for duplicate name check on mat…
Browse files Browse the repository at this point in the history
…rixes vs array + write (#52)
  • Loading branch information
SimonV-Skyline authored May 17, 2024
1 parent 4b6445c commit 597c31e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 33 deletions.
17 changes: 10 additions & 7 deletions Protocol/Helpers/ParamHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,16 +1180,19 @@ public static bool IsValidParamAssociation(IList<IParamsParam> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,26 @@ public void Param_CheckNameTag_DuplicatedValue()
FileName = "DuplicatedValue",
ExpectedResults = new List<IValidationResult>
{
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")),
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
<Protocol xmlns="http://www.skyline.be/validatorProtocolUnitTest">

<Params>
<Param id="100">
<Name>SameName</Name>
<Param id="100">
<Name>Duplicate_2Read</Name>
<Type>read</Type>
</Param>
<Param id="101">
<Name>Duplicate_2Read</Name>
<Type>read</Type>
</Param>

<Param id="200">
<Name>Duplicate_2Write</Name>
<Type>write</Type>
</Param>
<Param id="201">
<Name>Duplicate_2Write</Name>
<Type>write</Type>
</Param>

<Param id="300">
<Name>Duplicate_2Read_1Write</Name>
<Type>read</Type>
</Param>
<Param id="150">
<Name>SameName</Name>
<Param id="350">
<Name>Duplicate_2Read_1Write</Name>
<Type>write</Type>
</Param>
<Param id="101">
<Name>SameName</Name>
<Type>read</Type>
</Param>

<Param id="200">
<Name>SameName3</Name>
<Type>read</Type>
</Param>
<Param id="201">
<Name>SameName3</Name>
<Param id="301">
<Name>Duplicate_2Read_1Write</Name>
<Type>read</Type>
</Param>

<Param id="400">
<Name>Duplicate_1Read_1Table</Name>
<Type>read</Type>
</Param>
<Param id="401">
<Name>Duplicate_1Read_1Table</Name>
<Type>array</Type>
</Param>

<Param id="500">
<Name>Duplicate_1Write_1Table</Name>
<Type>write</Type>
</Param>
<Param id="501">
<Name>Duplicate_1Write_1Table</Name>
<Type>array</Type>
</Param>
</Params>

</Protocol>
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@

<!--Matrix-->
<Param id="101">
<Name>ArrayWrite</Name>
<Type>array</Type>
<Name>Matrix_Write</Name>
<Type options="dimensions=640,640;columntypes=102:0-639">array</Type>
<Measurement>
<Type>matrix</Type>
</Measurement>
</Param>
<Param id="151">
<Name>ArrayWrite</Name>
<Type>write</Type>
<Name>Matrix_Write</Name>
<Type options="dimensions=640,640;columntypes=102:0-639">write</Type>
<Measurement>
<Type>matrix</Type>
</Measurement>
</Param>
</Params>
</Protocol>

0 comments on commit 597c31e

Please sign in to comment.