Scott-
Even though the mocked class is definitely not a singleton, using MockAll solved the problem.
-Mark
Hi Mark,
I am happy that this solved the problem. Perhaps if I explain the difference between
Mock and
MockAll you will know why this solved the problem.
MockAll will mock ALL instances of a type, including instances that are already alive in the system. Mock will mock only the NEXT instance (or
new) of the type. In Factories and Singltons, the instance needed to be mocked is already alive the next time that the test is run, so
new won't be called and the mock won't be run.
As a rule it is better to use MockAll unless there are some instances that need to be mocked differently.
We should actually give a better Error when this happens and advice to use MockAll, I will add this to our feature list.