Note that there are some explanatory texts on larger screens.

plurals
  1. POUnit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?
    primarykey
    data
    text
    <p>I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following:</p> <ol> <li>IUtilisateur</li> <li>IGroupe</li> <li>IUniteOrganisation</li> </ol> <p>These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This will allow the architecture a better flexibility, etc.</p> <p>Now, I want to test these classes (Utilisateur, Groupe, UniteOrganisation) in a different project within the same solution. However, these classes are internal. I would like to be able to instantiate them without going through my façade, but only for these tests, nothing more.</p> <p>Here's a piece of code to illustrate it:</p> <pre><code>public static class DirectoryFacade { public static IGroupe CreerGroupe() { return new Groupe(); } } // Then in code, I would write something alike: public partial class MainForm : Form { public MainForm() { IGroupe g = DirectoryFacade.CreerGroupe(); // Doing stuff with instance here... } } // My sample interface: public interface IGroupe { string Domaine { get; set; } IList&lt;IUtilisateur&gt; Membres { get; } } internal class Groupe : IGroupe { private IList&lt;IUtilisateur&gt; _membres; internal Groupe() { _membres = new List&lt;IUtilisateur&gt;(); } public string Domaine { get; set; } public IList&lt;IUtilisateur&gt; Membres { get { return _membres; } } } </code></pre> <p>I heard of InternalsVisibleTo() attribute, recently. I was wondering whether it is available in VBNET 2.0/VS2005 so that I could access the assmebly's internal classes for my tests? Otherwise, how could I achieve this?</p> <p><strong>EDIT</strong> Is this a good testing practice to proceed like I do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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