Thursday, July 28, 2005

Visual Studio .NET IDE for Linux!

Check the latest Visual Studio .NET IDE for Linux! on code project or at http://dev.mainsoft.com/Default.aspx?tabid=45.

Monday, July 18, 2005

Using Configuration Files in NUnit

Using configuration file for NUnit is similar to web.config file in ASP.NET web application and application.config for executables.

What will you do when NUnit requires a .DLL assembly and your code has been written to use a configuration file? The answer is that you will create a configuration file for testing using NUnit J.

NUnit creates an instance of the AppDomain for the .DLL you are testing. One of the other things it does is to manually look for an assembly.dll.config file. Thus, if you need configuration options for your application, copy those settings into a .config file for testing. In our example, such a .config file would be MyDll.dll.config, placed in the same directory as the test DLL loaded by NUnit.

Lets say I have a method bool IsNum(string val) in my MyDLL class (MyDll.dll) which takes a string as parameter and if the string is a number is will return true else false.

What I want is that I create generic test using NUnit and different values passed to my IsNum method to test should be read from the config file. The test should be performed as many times as there are test values in my configuration file. So tomorrow if I want to pass a new value to see if my method is working correctly or not I just need to add a new entry in the config file.

This is my sample MyDll.dll.config file:




Place this config file with your test dll.

Now my Test method will look like:

[Test]
public void ValidateNumberTest()
{
NameValueCollection nvc = (NameValueCollection) ConfigurationSettings.GetConfig("ValidateNumberTest");
MyDll d = new MyDll();
string val = "";
for(int i=0;i< nvc.Count;i++)
{
val = nvc.Get(i);
Assert.AreEqual(true,d.IsNum(val));
}
}

I know this sample is not a great one but I think it gives a fair Idea how we can use a configuration file with NUnit.

Tuesday, July 12, 2005

Cracking .NET Assemblies

Today one of my friends send me a link of an article describing how to crack a .NET assembly. I liked this article very much and thought to put that link in my blog :).

http://www.grimes.demon.co.uk/workshops/fusionWSCrackOne.htm

This article describes how to crack and tamper a .NET assembly. It aslo explains the process of strong naming of an assemble and how to crack strong named .NET assemblies.

But the good news is that the approach explained in this article to crack and tamper .NET strong named assemblies does not work in new version of .NET i.e. this has been corrected in new version of .NET.