After creating some unit tests, I ran into a problem where the TestInitialization method was failing with either one of two errors.
The test initialization was performing something similar to:
public void Initialize()
myMock = MockRepository.GenerateMock<IMyInterface>();
myMock.Stub(m => m.NextValue()).Return(6).Repeat.Once();
myMock.Stub(m => m.NextValue()).Return(7).Repeat.Once();
myMock.Stub(m => m.NextValue()).Return(9);
The first error I might get on the GenerateMock would be:
Message=Object reference not set to an instance of an object.
Or, on one of the Stub calls I might get:
Message=Previous method ‘IMyInterface.MyMethod();’ requires a return value or an exception to throw.
This was a really frustrating problem and it took getting several people reviewing the problem with me before one individual spotted that two unit tests were running at once. The problem ended up being that using the parallelTestCount=”2″ attribute in the testrunconfig file and the total problem that using this creates. Trying to execute multiple tests at once would be great except for the fact that MSTest executes multiple parallel tests within the same test class. Rhino Mocks is also NOT multi thread safe.
So the next time you see these types of errors, check to see if you’re using a parallelTestCount greater than 1. It might save you a lot of time.
The languages got some major upgrades as well, C++ in particular. The list for C++ is far to long to go into. The F# asynchronous abilities show their influence in the async syntax in C# and VB.
The .Net framework is now even faster and even more support for building parallel and concurrent applications.
I mean the list is huge! Jason Zander did a great summary write up. It’s well worth your time and will give you some of the highlights.
As many of you know, our beloved tool .Net Reflector was bought by RedGate and is no longer free. The last free version is showing it’s age. Enter Telerik to the rescue. They are providing a FREE .Net Decompiler! And this is not some dumbed down version. It supports side-by-side assembly loading, .Net versions 1.1 through 4.0, Silverlight and Compact Framework, lambda expressions, generics, yield statements and auto generated properties. Telerik apparently didn’t think that was enough. They added the ability to create a full Visual Studio project from a decompiled assembly! And if that wasn’t enough, they do three major updates a year! Way to go Telerik!!!
Happy Coding! And decompiling!
When we’re building WCF services, we often want to debug our code. Creating a harness to host our service is easy enough but I’ve seen people open two instances of Visual Studio to do this. One to host and one to debug. However, that’s not necessary. The trick is to go to the Solution properties and set the “Multiple start up projects” and select which ones you wish to start. In my example, I have created a simple WCF service project, a project to contain my service contract, a console app to host the service in for testing and finally a project to actually make the call to my service. I can tell VS to start both my hosting program and my caller program by making the changes shown below.
Another way you could accomplish the same is to right click on the project you want to start, select debug and then select start new instance.
Script Junkie delivers another good post about using the <audio/> tag in HTML5. I really liked the table showing what codecs are supported in each browser. Thanks Emily!
Found an interesting post about the SQL ISNULL function. Apparently, it behaves differently if you’re using it to test strings. For example:
DECLARE @a VARCHAR(100)
DECLARE @b VARCHAR(10)
SET @a=’This is much longer than 10 characters‘
— This will display
— This is mu
— This will display
— This is much longer than 10 characters
SELECT ISNULL(CONVERT(NVARCHAR(MAX), @b), @a)
Knowing this could keep you from pulling your hair out trying to investigate a bug when the truncated data gets down the pipeline. Hope that helps someone out there.
I haven’t been as active on my Blog but I have been active on Twitter. I’ll work on the blog but in the meantime you can follow me at #JohnMarkHowell on Twitter!