Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi folks,

i need to write nunit test cases for the methods inside the private class
i tried this way, but it doesnt work for me.

...[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ATests")]...

is there is any other way to do write nunit test cases?
Posted

Hi,

I have used Private objects in MS Unit test cases. do not have much idea about NUnit but this may work for you as well.

Try to use PrivateObject class to access private object for testing.

In below link i have list out some information on accessing private object.

Creating Unit tests for your c# code[^]

Best luck
 
Share this answer
 
Here's The Link for NUnit TestCase Generator
NUnit Test Case Code Generator[^]
 
Share this answer
 
You need "Reflection" - object instantiation and method calls have to be done via reflection. It is not such easy as with MSTest, but it can be done.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900