.net (23)

NUnit factories

I was getting mad to find out how to use factories on NUnit. I’ve been using factory methods with MBunit and they’re definetly helpful when you need to execute a test using several imputs. What was confusing me is the NUnit documentation: I’ve googled something like “NUnit factory” and the first results were pointing me […]

Split string without breaking words

Let say we got a long string that need to be splitted in a series of rows (of a certain lenght) . If the length exceed, we need to go wrap the text on a new line ensuring words are not broken. The solution is quite simple after all, before going to the new line […]

Create an image from text (Updated)

I’ve done a few changes and some additions on the code of the previous post. The CreateTextImage now prints the text at the center of the image, this is done using the Alignment property of the StringFormat class: public Bitmap CreateTextImage(string imageText) { Bitmap outputImage = new Bitmap(1, 1); int imageWidth, imageHeight = 0; //setup […]