Having recently taken a look at NServiceBus, the first obstacle that I encountered was that it was not compatible with the version of Castle Windsor which we were using. Luckily due to the design of NServiceBus adding a new version of an IoC framework is relatively painless if you follow a couple of basic steps and follow the format laid out by the existing framework. Whilst the NServiceBus documentation say what you need to do, . . .
To fully test an MVC web site it is important to test (in isolation) the following: The behaviour of controller actions The behaviour of any custom action filters. The decoration of action filter attributes on controller actions. To test the 3rd point, you must use reflection to select the desired action from the controller. The following method takes an action name and a Tuple array of “Type” and “String”. Used together this combination should be . . .
Update – 14th February 2016:Looking in my blog stats, this continues to be one of my most popular articles, so it is most definitely worth an update. As of v4.2.0 Automapper has been updated to remove the static implementation. I’ve not had chance to play with the new version yet but I would imagine this version will now work with any IoC container you wish to use it with. Original Article:The main “Mapper” class of . . .
In my current role, we have come across a requirement to map message objects to more complex domain entities. As anyone that has done this previously will quickly tell you, manually writing code to do this is very boring and repetitive. With very limited time and resources, that effort could be better spent elsewhere on the project. As it seemed very simple to set up and start using we’ve decided to use AutoMapper. Configuring / . . .
When unit testing ASP.NET MVC2 projects the issue of injecting HttpContext is quickly encountered. There seem to be many different ways/recommendations for mocking HttpContextBase to improve the testability of controllers and their actions. My investigations into that will probably be a separate blog post in the near future but for now, I want to cover something that had me stuck for longer than it probably should have. That is how to mock non-abstract/interfaced classes within . . .
I’ve just spent a useful and enjoyable day finally getting around to reading Clean Code, definitely a book to come back to time and again for reference, etc. However, given the subject matter, the book contains I was amazed to find in the section about “magic numbers” a statement that “some constants are so easy to recognise that they don’t always need a named constant”. Two of the examples given are the number of feet per . . .
Today I read Roy Osherove’s blog post “Two Different ways to create bad logic in unit tests“. It’s an interesting article that covers logic included in many unit tests, is it acceptable to compare a returned string value using a comparison value built via string concatenation? It is perfectly possible that an issue introduced by the concatenation process is duplicated in both the code and the unit test – more often than not the logic . . .
The challenge set by problem 18 was By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. A 15-row triangle was then supplied for which the program must determine the corresponding maximum value taking a similar path . . .
The challenge set by Problem 54 was to determine the number poker games payer 1 won given a text file detailing 1,000 hands dealt to 2 players. Given the logical nature of the rules, the solution was just a case of finding the best way to 1) implement the rules and 2) duplicate the rule hierarchy. I quickly re-factored my first attempt that attempted to place the ruled based logic inside of the PokerHand class . . .
I’ve just spent a very painful hour or so debugging a jQuery issue that turned out to be a self inflicted problem! The site I was working on had been working perfectly all morning, then a particular page began to fail on a refresh (browser F5). It was possible to browse to the page and it displayed correctly, but press F5 to refresh the page and it failed on the statement below. Checking the contents . . .