Testing friend/internal methods

"Christian Jordan" <[email protected]> Wed, 6 Aug 2008 14:34:09 +0200
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Hello,

I would like to test methods, that are declared as friend (vb) /
internal (c#). I read older threats to this theme, and I know that
placing the tests in the same project would help. But as you might
understand, I want a separate testing-dll. Declaring these methods as
public is another solution but after that I must remind me to set the
visibility-level back to friend when I make a release. To my mind, that
is not in the philosophy of unit-testing. Inheritance is another
solution, but in this case i also have to change the visibility from
friend to protected. And there are additional problems with constructors
as well.
Finally, I found the last solution to declare an assembly as "friend":

'Class to test
Imports System.Runtime.CompilerServices
<Assembly: InternalsVisibleToAttribute("AssemblyWithTest")>
'...

With this option, you can use friend-methods in the test-assembly.
But unfortunately not in VB 2005. This is a well known problem with the
VB-Compiler. OK, so I wrote the tests in C# and then the access to the
method worked. But now I have other problems, for instance when I try to
use a property. Although the test.dll (written in c#) compiles without
errors, executing the test (that accesses methods written in VB) caused
an exception:

System.MissingMethodException : Methode nicht gefunden: Void
Tranche.set_NameOfProperty(...).

Maybe someone of you has a hint or a comment. If not, it is maybe better
to say goodbye to testing friend / internal methods, but that would be a
pity.

Greetings


Sitz der Gesellschaft: Hamburg; Amtsgericht Hamburg HRA 104052 
Persönlich haftende Gesellschafterin:
LichtBlick Verwaltungsgesellschaft mbH; Amtsgericht Hamburg HRB 97446
Geschäftsführer: Wilfried Gillrath, Heiko von Tschischwitz

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users