Archive for the ‘Unit testing’ Category

Convert file extension to MIME type - extended

In my last post I wrote a sample class that converts file extension to MIME type. Is it obvious that in many cases it is much better to have configurable list of mappings. For instance, you may have a configurable “white list” of file extensions that your web application allow to be uploaded and then [...]

Unit test LINQ to SQL

The idea to write this post appears in my head just now when I’m starting to create a small  application that uses Entity Framework and I need to do unit testing. The solution described here is useful for LINQ to SQL. I plan to try using the same solution also with Entity Framework. I hope [...]

[Rhino.Mocks] System.InvalidOperationException : Can set only a single return value or exception to throw or delegate to execute on the same method call.

Today I got this exception during my unit testing and I was a bit confused because of it and the situation that I got it. I have a class that is used by another class. I also have an interface for it but in this specific case I wanted to have a partial mock in [...]

Using TestCase arrtibute of NUnit

Sometimes ago NUnit extend their framework with a possibility to specify parameters via an attribute and then these parameters are reused by NUnit run-time and the test method is executed several times with different parameters. An example: let’s assume that we have a method that concatenates person first name and person last name.

[...]

Another way to unit test a class that retrieves information from a file

In my previous post I wrote that a unit test that uses a real file on a disk is more like an integration test than as a unit test. Well, I think that I wasn’t completely right because if you write a test that creates a file before the test and after the test your [...]

Unit testing a class that retrieves information from a file

Sometimes we should develop a class that will load some information from a file and to store this information in some object-oriented form in order to be further used by other application classes. In this post I’ll try to share with you how I’ve developed such a class for my SQLCEPad tool using TDD practices. [...]