---
title: "Isolator Feature Focus: Duck Typing and Isolate.Swap"
url: "https://osherove.com/blog/2008/11/2/isolator-feature-focus-duck-typing-and-isolateswap.md"
canonical: "https://osherove.com/blog/2008/11/2/isolator-feature-focus-duck-typing-and-isolateswap.html"
published: "2008-11-02T05:25:00"
updated: "2008-11-02T05:25:00"
tags: [".NET", "Agile", "Art Of Unit Testing", "FeatureFocus", "Typemock", "Unit Testing"]
author: "Roy Osherove"
description: "Typemock Isolator 5.1.1 has been released, and this release brings with it some awesome (seriously) features that are unique fro any other framework I've seen. a good overview of features can be found here . The…"
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/"
---

# Isolator Feature Focus: Duck Typing and Isolate.Swap

By Roy Osherove November 2, 2008 In [.NET](https://osherove.com/blog/category/net), [Agile](https://osherove.com/blog/category/agile), [Art Of Unit Testing](https://osherove.com/blog/category/art-of-unit-testing), [FeatureFocus](https://osherove.com/blog/category/featurefocus), [Typemock](https://osherove.com/blog/category/typemock), [Unit Testing](https://osherove.com/blog/category/unit-testing)

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

[Typemock Isolator 5.1.1](http://www.typemock.com/commdl.php) has been released, and this release brings with it some awesome (seriously) features that are unique fro any other framework I've seen.

a [good overview of features can be found here](http://blog.typemock.com/2008/10/typemock-isolator-511-is-out.html).

**The Isolator Swap feature** allows swapping calls between real and fake objects (kind like redirects) so that any relevant calls made against the real object will be redirected and invoked on the fake object.

**Here's how you use it:**

![image](https://osherove.com/img/wb/.net_blogs_rosherove_WindowsLiveWriter_IsolatorFeatureFocusDuckTypingandIs.Swap_CC8A_image_thumb.png)

Unlike doing a standard "WhenCalled()" on some object method and telling what its custom behavior will be, "Swapping"  objects redirects **all** relevant calls(I'll explain what "relevant" means in a second) to the fake object which you have created.

 **Duck Typing Awesomeness**

Another cool thing about it is that "Duck" and "Dog" don't have to have a shared interface or base class. The "Swap" feature will redirect a method call if it exists on the "fake" object, but if it does not, it will invoke the original object. This is one interpretation of what's called "[Duck Typing](http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx)".

The "CallsOn" and "WithCallsTo" methods take an object type, so you can send in anything you want.  if a method on the fake object matches the signature and name of a called method on the real object, the fake method will be invoked.

## Lessons on this topic

- [Working with Typemock Isolator](https://courses.osherove.com/courses/tdd-in-net-in-hebrew/working-with-typemock-isolator/) · TDD in .NET in Hebrew

## More in .NET

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

- 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)

- Oct 28, 2008

    ### [PDC 2008 Videos](https://osherove.com/blog/2008/10/28/pdc-2008-videos.html)

- Oct 15, 2008

    ### [Use Reflection to find Methods that implement explicit interfaces](https://osherove.com/blog/2008/10/15/use-reflection-to-find-methods-that-implement-explicit-inter.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/
