In my last question: Best practice for testing modules? / C # InternalsVisibleTo () for VBNET 2.0 during testing? I asked about InternalsVisibleToAttribute.
I read the documentation on how to use it, and everything is fine and understandable. However, I cannot create an instance of the Groupe class from my testing project.
I want to be able to instantiate my inner class in my wrapper assembly, from my test assembly.
Any help is appreciated!
EDIT NO. 1
Here is the compile-time error that I get when I try to create an instance of my type:
Erreur 2 'Carra.Exemples.Blocs.ActiveDirectory.Groupe' n'est pas available for use with the conveyor, 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
(This suggests that my type is not available in this context because it is private.) But he is Friend (inner)!
EDIT No. 2
Here is the code snippet proposed for the Groupe class that implements the Public Interface IGroupe:
Imports System.DirectoryServices
Imports System.Runtime.CompilerServices
<Assembly: InternalsVisibleTo("Carra.Exemples.Blocs.ActiveDirectory.Tests")>
Friend Class Groupe
Implements IGroupe
Private _classe As String = "group"
Private _domaine As String
Private _membres As CustomSet(Of IUtilisateur)
Private _groupeNatif As DirectoryEntry
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
And the code is trying to use it:
Imports NUnit.Framework
Imports Carra.Exemples.Blocs.ActiveDirectory
<TestFixture()> _
Public Class GroupeTests
<Test()> _
Public Sub CreerDefaut()
Dim g As Groupe = New Groupe()
Assert.IsNotNull(g)
Assert.IsInstanceOf(Groupe, g)
End Sub
End Class
EDIT No. 3
Heck! I just noticed that I did not import the assembly in my import region.
No, nothing decided = (
Thank!