Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« Isolation frameworks – lessons from the wild | Main | Announcing Isolator for Sharepoint with a free full license for bloggers »
Wednesday
Nov262008

Isolation Syntax for VB.NET - Your comments please

I'm working on adding a VB.NET Friendly syntax for Typemock Isolator. If you're into VB, I'd love your input on the usability of this API and how to make it better.

We'll start going through several basic scenarios that you can do using Typemock Isolator, and show them in VB proposed syntax:

  • Faking instances of classes or interfaces
  • Setting Stub return values or errors on methods
  • Verifying the methods were called
  • Swapping calls between two types
  • Swapping future instances
  • Faking Non Public Members

 

Faking instances of classes or interfaces

the method Fake() is part of a Module called "Test" so it can be used from the tests easily. You could also write Test.Fake(..) if you wanted.

image

 

Setting Stub return values or errors on methods

here are three examples of returning a fake result from a method or a bunch of methods (below). ThisCall(s) is located on the Module Test so you can also write Using Test.ThisCall.WillThrow(...) if you wanted to.

 

image

Verifying that methods were called

This would go at the end of an interaction test

image

Here's an example of a full Arrange-Act-Assert in a test using VB and fakes:

image

 

One possible thing I am considering is adding Arrange-Act-Assert "Regions" to the test by taking advantage of the "Using" feature:

image

Question #1: What do think about the custom Arrange-act-assert regions? (they are option to use anyway)

Swapping calls between two types

This is the "duck typing" feature we introduced in Isolator: allowing you to make calls on one object be invoked on another, without them sharing the same interface, as long as the method names match.

image

Swapping future instances

Isolator supports faking the next creation of an object type, and replace that with the fake we create:

image

Faking Non Public Members

image

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>