Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Internal enum ?
Message
De
28/05/2014 01:59:24
 
 
À
27/05/2014 16:21:55
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01600724
Message ID:
01600757
Vues:
50
>I read an interesting blog post several years ago talking about how to test "hidden" functionality in a class. The summary was to just make everything public, since you really should be developing against an interface instead of the implementation. You can achieve your hidden visibility goal though the interface.

Can't see that argument. You can provide an interface but that won't prevent others using other public by casting to the class ? Plus you can't put an enum in an interface.


>>Why not just make it public? Internal is meant to be well internal and if you need to expose outside of the original assembly you probably should use public.
>>
>>Friend behavior can be useful, but you really have to ask yourself whether it's worth the hassle for a semantic aspect to try to preserve internal visibility - especially for a constant (enum) that has no functionality that can be abused externally.
>>
>>+++ Rick ---
>>
>>>Hi everybody,
>>>
>>>I introduced internal enum in my class. I have a method that returns value of that enum. I want to be able to test that method in a test project which is part of my solution.
>>>
>>>I added the following line to my class code at the very top
>>>
>>>
>>>[assembly: InternalsVisibleTo("TestProject")]
>>>
>>>As a result I am able to see the methods of the class, but I am unable to declare a variable of the type my enum.
>>>
>>>Other than making that enum public is there another solution?
>>>
>>>Thanks in advance.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform