Isolator’s New VB.Net-Friendly API

In version 5.2 we’re introducing a new set of API which for VB developers. Let’s start with…

Why?

We already have VB support in Isolator. It’s already there in full glory in Natural and Reflective mocks. The difference starts with AAA. Because the C# AAA API is based on Lambda Expressions, VB users can use only part of it. I won’t go into details, but it’s because of the VB support for Function(Of T) but not for Action(Of T). So we could wait for the next VB version (in VS2010) to come out. We decided not to wait.

We see Arrange-Act-Assert as the way to go. We’re adding features to the C# API all the time, and we don’t want to see VB developers left behind. Truth is, we see a big opportunity in the VB market, to help introduce VB developers to unit testing and isolation with Isolator.

So here comes the new VB API. It is also AAA in nature. There’s a new assembly called Typemock.Isolator.VisualBasic that you reference from your VB test project, and presto! you have all the features of our AAA C# API in VB. Obviously going forward all the neat features going into both versions.

Here’s an example of a the new API:

The C# developers can identify the FakeInstance (which is similar to Fake.Instance). The WillReturn also seems familiar but it comes in a Using block. The equivalent of Isolator.Verify is AssertCalls, which is also used in a Using block. A nice VB API feature is that with the Using block you can have multiple functions and properties returning the same value, or use the AssertCalls block for multiple functions. (for C# developers who finally feel VB envy – you can reference this assembly and use it as well).

One difference to note in the Visual Basic version of WillReturn. It is not type-safe, meaning, the compiler allows you to write instead of the Single value 100.0F, let’s say a string “100.0F”, although CalculatePrice returns a Single. Isolator will find this at runtime, and will throw an exception.

Stay tuned. There’s more to come.