Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

Isolate.Swap.AllInstances - obsolete

+2 votes
I have been using the following code until now:

I can see that this has been marked as Obsolete, and that I should use Isolate.Fake.AllUnstances, but how do I pass a parameter (as I did with Swap and the With(...) method) to a pre-assigned instance?

asked Mar 27, 2013 by MartinH (1,500 points)

2 Answers

0 votes

Isolate.Fake.AllInstances<>(); returns a proxy object on which you should set the desired behavior.


public class UnitTest1
    public void IsolateFakeAllInstances()
        var allFakeFoo = Isolate.Fake.AllInstances<Foo>();
        Isolate.WhenCalled(() => allFakeFoo.GetNum()).WillReturn(5);

        var foo = new Foo();
        Assert.AreEqual(5 , foo.GetNum());

public class Foo
    public int GetNum()
        return 3;

You can find more info here.


Alex Galin | Support Team

answered Mar 28, 2013 by alex (17,950 points)
+2 votes
Great, thanks.
answered Apr 2, 2013 by MartinH (1,500 points)