I have a similar issue to these threads:
My issue is with extension methods. I have an extension method for a list called RandomItem. As you could guess, it returns a random item from the list. Now I have a unit test on a function that uses the extension method. So I mock that extension method in the unit test so that I can determine what item comes back so I can verify the expectation. I can run that test by itself all day long and the mock works.
However, I have another set of tests that actually test the logic of the extension method. When these run with it then the mock on the extension method fails. Generally I would use something like Mock.Initialize or Mock.Partial but it wont even let me do something like this:
because it is a static class. So I tried this stuff:
Mock.Partial<List<IDataItem>>().For(x => x.RandomItem());
But it still fails. Any ideas?