Note that there are some explanatory texts on larger screens.

plurals
  1. POUnit Testing using InternalsVisibleToAttribute requires compiling with /out:filename.ext?
    primarykey
    data
    text
    <p>In my most recent question: <a href="https://stackoverflow.com/questions/2827051/unit-testing-best-practice-c-internalsvisibleto-attribute-for-vbnet-2-0-whi">Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?</a>, I was asking about InternalsVisibleToAttribute.</p> <p>I have read the documentation on how to use it, and everything is fine and understood. However, I can't instantiate my class Groupe from my Testing project.</p> <blockquote> <p>I want to be able to instantiate my internal class in my wrapper assembly, from my testing assembly.</p> </blockquote> <p>Any help is appreciated!</p> <p><strong>EDIT #1</strong></p> <p>Here's the compile-time error I get when I <em>do</em> try to instantiate my type:</p> <blockquote> <p>Erreur 2 'Carra.Exemples.Blocs.ActiveDirectory.Groupe' n'est pas accessible dans ce contexte, car il est 'Private'. C:\Open\Projects\Exemples\Src\Carra.Exemples.Blocs.ActiveDirectory\Carra.Exemples.Blocs.ActiveDirectory.Tests\GroupeTests.vb 9 18 Carra.Exemples.Blocs.ActiveDirectory.Tests</p> <p>(This says that my type is not accessible in this context, because it is private.) But it's Friend (internal)!</p> </blockquote> <p><strong>EDIT #2</strong></p> <p>Here's a piece of code as suggested for the Groupe class implementing the Public interface IGroupe:</p> <pre><code>#Region "Importations" Imports System.DirectoryServices Imports System.Runtime.CompilerServices #End Region &lt;Assembly: InternalsVisibleTo("Carra.Exemples.Blocs.ActiveDirectory.Tests")&gt; Friend Class Groupe Implements IGroupe #Region "Membres privés" Private _classe As String = "group" Private _domaine As String Private _membres As CustomSet(Of IUtilisateur) Private _groupeNatif As DirectoryEntry #End Region #Region "Constructeurs" Friend Sub New() _membres = New CustomSet(Of IUtilisateur)() _groupeNatif = New DirectoryEntry() End Sub Friend Sub New(ByVal domaine As String) If (String.IsNullOrEmpty(domaine)) Then Throw New ArgumentNullException() _domaine = domaine _membres = New CustomSet(Of IUtilisateur)() _groupeNatif = New DirectoryEntry(domaine) End Sub Friend Sub New(ByVal groupeNatif As DirectoryEntry) _groupeNatif = groupeNatif _domaine = _groupeNatif.Path _membres = New CustomSet(Of IUtilisateur)() End Sub #End Region </code></pre> <p>And the code trying to use it:</p> <pre><code>#Region "Importations" Imports NUnit.Framework Imports Carra.Exemples.Blocs.ActiveDirectory #End Region &lt;TestFixture()&gt; _ Public Class GroupeTests &lt;Test()&gt; _ Public Sub CreerDefaut() Dim g As Groupe = New Groupe() Assert.IsNotNull(g) Assert.IsInstanceOf(Groupe, g) End Sub End Class </code></pre> <p><strong>EDIT #3</strong></p> <p>Damn! I have just noticed that I wasn't importing the assembly in my importation region.</p> <p><em>Nope, didn't solve anything</em> =(</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload