I have two unit tests that use TypeMock Isolator to isolate and fake a method from asp.net's SqlMembershipProvider.
In test 1 I have:
Isolate.WhenCalled(
() =>
Membership.CreateUser(...)))
.WithExactArguments()
.WillThrow(new Exception());
In test 2 I have:
Isolate.WhenCalled(
() =>
Membership.CreateUser(...)))
.WithExactArguments()
.WillReturn(new MembershipUser(...));
When I run each test by itself they both pass successfully.
When I run both tests, test number 1 runs first and passes, then test number 2 runs and fails with the exception thrown in test 1.
Why would the WillThrow()
instruction in test 1 "bleed over" to test 2? After all, test 2 explicitly defines different behavior - WillReturn()
?
Isolated
attribute, or are you callingIsolator.Cleanup
to reset the behaviour? typemock.com/rule-missing-isolated-attribut – Jaquith[Isolated]
attribute fixed the issue. Would you like to post this as an answer so I can accept it? – Ecclesia