VS Unit Test Progress Indication

If you do unit tests (and if not, you should), chance is once in a while a test will, (perhaps by design), take a long time to complete.

Visual Studio’s Unit Testing Framework frontend gives an indication of progress between different tests, but not what the running test is doing (this seems to be the case even for VS2012).

In some cases, for example, when doing a sanity check on generated DB tables, it would be more helpful to know what the current test is doing and perhaps when it will finish.

I’ve had this situation a few times and the solution, although not very elegant, seems to be to spawn your own UI thread that does the job. I haven’t been able to find some ready code to do the job, so I did my own.

As a minimum, you need add a reference to these two assemblies in your test project:

  • System.Windows.Forms
  • System.Drawing

This is because they are required in order to build our UI. With those in place, one just needs to instantiate the UI in a new thread (in Single Threaded Apartment mode). From then on, it’s a matter of updating the form as desired (but keeping in mind we’re doing this across threads, so SetControlPropertyThreadSafe() is required).

The code for all of this can be found on GithHub (of course). Enjoy!

Sophisticated Spam Attacks

In a recent status on Facebook, I remarked how spam started to act slightly intelligent, making use of my surname to give it a sense of authenticity.

Still, it is miles away from anything that looks remotely realistic. What’s the chance anyone wins a $1 billion lottery from a relatively unknown bank in the middle of Africa?

The exaggerated story, together with middle-east names and terrible spelling/grammar mistakes makes spam relatively easy to:

  • identify intelligently
  • filter by looking at common patterns

 

If I were a spammer, what would I do?

First of all, find a real story writer. Even my 9-year-old sister could come up with believable stories.

Secondly, make sure the writer knows the language. It can’t be that hard in this era…there are plenty of online proofreaders around!

Thirdly, bulk email lists are overrated. Think of every victim of yours as a potential customer; so you need to “advertise” your service in a way the user must really fall for.

For example, I noticed that loads of people leave out email addresses in source code hosted on github/bitbucket/etc. One can easily link up the full name and email in the source with, say, a Linkedin profile. If, for instance, you know this particular person is a fan of PHP, send him/her an email regarding a PHP-script-writing competition he just won! 😀