The (Unofficial) ITWorx Technical Architecture Blog

Archive for the ‘Unit Testing’ Category

Testing Webservices with NUnit

Posted by archworx on July 1, 2007

Because NUnit is an exe and you sometimes you need to access web.config and objects that are only present in a web context, you will need to do the following:

– Open the command prompt and cd to C:\Program Files\Microsoft Visual Studio 8\VC, or in Visual Studio 2005 Command Prompt, type wsdl url (where url is the WSDL URL). A C# file will be generated with the name of the webservice. You can add some command line arguments to change the file name or the language. Just type wsdl without any arguments to show the help.

– Move the file to your test project and use it. It will call the webservice 🙂

There’s a great article about Implementing Service-Oriented Integration with ASP.NET .. check it out.


Posted in El-Geish, Unit Testing | 4 Comments »

Testing Private Methods

Posted by archworx on June 21, 2007

Test Driven Development a practice that is becoming very popular due to the quality assurance that it adds. While it is easy to test public methods, How do I test private methods?

There are 2 ways:

  1. Using Helper Class discussed on The Code Project
  2. Using Microsoft’s build in Testing Tools


using Microsoft.VisualStudio.TestTools.UnitTesting;
PrivateObject po = new PrivateObject(new TestClass());
po.Invoke('PrivateMethodName'); /*This will invoke the private method*/
po.GetField('PrivateFieldName'); /*This will get the value of a private variable*/

Posted in Unit Testing, YShahin | Leave a Comment »