Runtime: Unit tests missing for MutexSecurity, SemaphoreSecurity, EventWaitHandleSecurity

Created on 13 Oct 2020  路  7Comments  路  Source: dotnet/runtime

Currently we only have one unit test file testing MutexSecurity, and contains only one unit test that verifies the parameterless constructor:
https://github.com/dotnet/runtime/blob/6072e4d3a7a2a1493f514cdf4be75a3d56580e84/src/libraries/System.Threading.AccessControl/tests/MutexSecurityTests.cs#L6-L16

We also need test classes to verify SemaphoreSecurity and EventWaitHandleSecurity as well.

area-System.Threading test enhancement

Most helpful comment

@carlossanlop is the code owner. I can say more generally: we try to test only through public API and we should do that if at all possible. Amongst other reasons that makes it easier to refactor the product code. In the rare instances where it isn't good enough, it is possible to use InternalsvisibleToAttribute but compiling selected product source files into the test assembly is preferable. This is the approach taken to test the Uri class. But we should make every effort to test through public API.

All 7 comments

Hi, would you mind me working on this? I would love to pick it up.

Hi @eugene-shcherbo yes, for sure - I assigned to you.

Thank you @danmosemsft

Hi @carlossanlop, @danmosemsft . I wonder if we want to cover with tests internal methods of the mentioned classes. I'm asking because now the assembly with code seems not to expose its internal members to the tests assembly. Therefore I would gladly discuss with you (when you have time) what you think of it and if we should do something with this.

My opinion is that it would be good to test them, at least the tests would be like an additional documentation, but I'm not sure what issues addding the InternalsVisibleToAttribute attribute can cause, so looking forward to your opinions or advice, guys. Thanks!

@carlossanlop is the code owner. I can say more generally: we try to test only through public API and we should do that if at all possible. Amongst other reasons that makes it easier to refactor the product code. In the rare instances where it isn't good enough, it is possible to use InternalsvisibleToAttribute but compiling selected product source files into the test assembly is preferable. This is the approach taken to test the Uri class. But we should make every effort to test through public API.

@danmosemsft I get the idea, makes sense actually. Thank you for the answer, this is very useful to know. And apologizing for mentioning you in the question especially if I distracted you.

You are welcome to mention me any time!

Was this page helpful?
0 / 5 - 0 ratings