Hi Colin,
I'm using the MockAll functionality and cant find a way to switch it off once a test is done, is there any way to do this?
There are a few ways to stop mocking (Sorted in preferred way first):
:arrow:
MockManager.Verify()
This will Clear the mocks as well, although it might lead to test faliures if expected calls from other tests where not called. This should actually be called after each test in the [TearDown] to avoid tests accidently using another tests' expectations
:arrow:
MockManager.Init()
This will clear all the expectations
:arrow:
theMock.Clear()
This clears the expectations of the mock
:arrow:
MockManager.GetMockAll(typeof(MyType)).Clear()
This does the same as above but you can use this if you don't have access to the mock variable (You can use
IsTypeMockedAll to check if the type is mocked at all)
:arrow:
theMock.Clear("TheMethod")
This clears the expectation of "TheMethod" method of the mock
:idea: Using the
Enterprise Edition you can set some expectations in a 'Block' and clear just that block, this way you can have some test that use all the expectations and others use only part of the expectations
Hope this helps