BANGALORE, INDIA: There is a debate in the Test Driven Development (TDD) community about whether or not it's appropriate to test private methods with unit test tools like NUnit. By default NUnit will not allow you to test private methods. But you can test private methods using .NET's Reflection API.
To call a class' private method, instantiate a Type object for the class. Then call the Type object's GetMethod method, specifying BindingFlags.Private. You'll also need to specify BindingFlags.Static if the method is static.
Once you've called GetMethod, you'll have a MethodInfo object for the method. Finally, call the MethodInfo object's Invoke method to call the private method.
Click here for more...!
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.