[Mono-dev] Unit testing when it's protected

Martin Thwaites monoforum at my2cents.co.uk
Wed Oct 22 23:13:45 UTC 2014

Hi All,

I'm currently putting together the MembershipPasswordAttribute class, and
writing some unit test, but it occurs to me that I actually can't test it
properly due to the fact that one of the overrides needed is protected.

What I came up with was to derive a test class from the attribute and add a
public method that internals calls the protected one and returns the result.

My question is, is that a valid way to write a test in mono?

Here's the example:


The other thing is, I'm creating these tests by simply building a unit test
on windows against .NET, and find error message text etc. as I go and
refactoring the test so it passes on .NET.  The idea being I then simply
run the same tests against linux and fix until they all pass.

Is that a valid approach? I'm not decompiling, just hitting the API to find
out the valid results and then writing asserts around them?  I just don't
want these contribution to be poisoned by doing it the wrong way.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20141023/77f98ed2/attachment.html>

More information about the Mono-devel-list mailing list