Today, we finally found a way to run NUnit tests in .Net 4 assemblies in TeamCity! Here’s the solution:
SQLite and unit testing is a great combination for testing database operations without having to manage database files. You can simply create an in-memory database in your setup code and work with that instance. Perfect in combination with NHibernate, for example.
If you want to do this in the current .Net 4.0 beta you’re out of luck though, you’ll get an exception:
System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
The solution is pointed out by Jomo Fisher. What you do is to include this snippet in the application config file:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
When unit testing assemblies that references System.Data.SQLite.DLL then you have to put that snippet in NUnit’s config file (C:\Program Files\NUnit 2.5.2\bin\net-2.0\nunit.exe.config).
If you combine this with the tip in my post NUnit with Visual Studio 2010 Beta 2, you should insert the following
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> <requiredRuntime version="v4.0.20506" /> </startup>
<loadFromRemoteSources enabled="true" />
under the runtime tag.
This works for me, hopefully it will for you as well.
I just found a very useful XSD for editing log4net configurations:
Just copy the schema file to C:\Program Files\Microsoft Visual Studio *\Xml\Schemas and add the correct namespace to the log4net element in your config file:
<log4net xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Here’s a tip of how to run NUnit tests in .Net 4 code:
Note that it’s the NUnit.exe.config file in C:\Program Files\NUnit 2.5.2\bin\net-2.0 that should be updated.
If you’re not familiar with NDepend, it can be described as a tool to analyze a set of .Net assemblies for code quality. I suppose its name indicates that it originally was focused on analyzing dependencies but these days that name is rather misleading, in my opinion, as it can do much more that that. I’ll go through some of its capabilities below.
When you first analyze a set of assemblies, NDepend displays a screen similar to this:
If you’re like me, then you didn’t check out any tutorials or web casts before running the tool and your first reaction is likely “Holy cow! What’s all this?” or something similar. 🙂
It turns out that there is a ton of useful information in these displays but you have to know how to interpret them which takes a little learning.
Briefly, here’s what I gathered so far:
In addition to the displays described above, an HTML report is also generated after analyzing assemblies. It displays much of the same information as the graphical and interactive displays above, but also contains the “Abstract vs instability diagram”:
Obviously you want to be in the green area with all your assemblies, but the dimensions used might not be completely clear at first sight. This seems to be a good article describing it it detail.
So, what are my first impressions? Well, I must say that NDepend really is a very powerful tool for analyzing code but it does require investing some time to use its many features properly. To me, that seems like an investment well worth doing.
Let’s take a break and post a tip about my favorite hobby, photography and image editing…
Look here for some fantastics images and tips of how to create them: http://www.smashingmagazine.com/2009/04/22/the-ultimate-photography-round-up
This is really stunning stuff!
This is a handy tip for removing (or lessening) haze from an image using the unsharp mask filter found in most image editing programs. Normally that filter is used for sharpening an image, but it has more uses…
Here’s an image of the Chrysler Building in New York (taken from the Empire State Building if you’re curious). It was a hazy day when I took the picture so the image low contrast:
This haze can be fixed using the Unsharp mask filter. The dialog looks like this in Photoshop Elements 5:
I use the following values:
The resulting image is much better:
As hazy images are almost inevitable when shooting outside with long distances, I thought this might make a good tip. BTW, I first saw it in a Swedish Photo mag called “DigitalFoto för alla”.
The GIMP is a great, free image manipulation program. It can do a lot but it’s not always obvious how it can perform a certain task.
For example, creating a transparent GIF was something I could not find how to do. Luckily, there are other bloggers out there to help:
The Gimp: Making Colors in a GIF Transparent (A.P. Lawrence).
Good tip and it works great.