Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Internal enum ?
Message
From
28/05/2014 05:58:51
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01600724
Message ID:
01600759
Views:
51
>>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.
>


>Plus you can't put an enum in an interface.

Well, sort of -
	enum Colour
	{
		Red, Green, Blue
	}
	interface IColour
	{
		Colour TheColour { get; set; }
	}

	class ColourClass : IColour
	{
		public Colour TheColour { get; set;}
	}
>
>>>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.
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform