I just put together the following code based on your snippets and it passes fine for me under NUnit 2.4.6 and Typemock Isolator 4.2.3:
public class AmazonS3Wrapper
{
public static AmazonS3Wrapper Instance()
{
throw new Exception("We should never get here - we're mocking.");
}
}
[TestFixture]
[VerifyMocks]
public class MyTestFixture
{
[Test]
public void MyTest()
{
using(RecordExpectations recorder = RecorderManager.StartRecording())
{
AmazonS3Wrapper.Instance();
recorder.Return(null);
}
AmazonS3Wrapper wrapper = AmazonS3Wrapper.Instance();
Assert.IsNull(wrapper);
}
}
You'll notice I truncated the contents of the Instance method. Since you're mocking it, the contents never get executed so we know the problem isn't in there - we can remove it so it doesn't confuse the issue. By throwing an exception, we know that if we get the exception then mocking setup isn't happening right and that's where we should start looking.
What I'm suspecting is happening is you're seeing an error for something else - some code you didn't post. Generally when I run into these problems it's because I've got something else in the test or in the test setup that is mocking something it shouldn't be mocking (or is setting up mocking incorrectly).
Check out the rest of your test code and test setup code. If it's still not working, I recommend creating a very small reproduction - that is, a whole separate project with a whole separate test fixture and a minimal copy of the code you're working with. (Something small like what I posted). See what the smallest amount of code is that is required to get the error.
If you still can't figure it out, post your small repro and we can work it out from there.