---
title: "Isolation Syntax for VB.NET - Your comments please"
url: "https://osherove.com/blog/2008/11/26/isolation-syntax-for-vbnet-your-comments-please.md"
canonical: "https://osherove.com/blog/2008/11/26/isolation-syntax-for-vbnet-your-comments-please.html"
published: "2008-11-26T03:15:14"
updated: "2008-11-26T03:15:14"
tags: [".NET", "Agile", "Typemock", "Unit Testing"]
author: "Roy Osherove"
description: "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…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Isolation Syntax for VB.NET - Your comments please

By Roy Osherove November 26, 2008 In [.NET](https://osherove.com/blog/category/net), [Agile](https://osherove.com/blog/category/agile), [Typemock](https://osherove.com/blog/category/typemock), [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published November 26, 2008; technical details may be outdated.

**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](https://osherove.com/img/wb/afb3fe4b_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb.png)

**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](https://osherove.com/img/wb/82f962b2_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_1.png)

**Verifying that methods were called**

This would go at the end of an interaction test

![image](https://osherove.com/img/wb/8bc4aace_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_2.png)

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

![image](https://osherove.com/img/wb/e9ceae9f_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_3.png)

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

![image](https://osherove.com/img/wb/bba5b7d4_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_4.png)

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](https://osherove.com/img/wb/4b5730c1_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_5.png)

**Swapping future instances**

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

![image](https://osherove.com/img/wb/4d02ac35_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_6.png)

**Faking Non Public Members**

![image](https://osherove.com/img/wb/fa724d9b_weblogs.asp.net_blogs_rosherove_WindowsLiveWriter_70cfa7951aa0_A7DA_image_thumb_7.png)

## More in .NET

[All posts in .NET](https://osherove.com/blog/category/net)

- Dec 31, 2008

    ### [The morning brew](https://osherove.com/blog/2008/12/31/the-morning-brew.html)

- Dec 3, 2008

    ### [Isolation frameworks – lessons from the wild](https://osherove.com/blog/2008/12/3/isolation-frameworks-lessons-from-the-wild.html)

- Nov 24, 2008

    ### [Announcing Isolator for Sharepoint with a free full license for bloggers](https://osherove.com/blog/2008/11/24/announcing-isolator-for-sharepoint-with-a-free-full-license.html)

- Nov 2, 2008

    ### [Isolator Feature Focus: Faking Collections](https://osherove.com/blog/2008/11/2/isolator-feature-focus-faking-collections.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
