I have a couple of calls like this in my class to be testet, here a snippet:
I'm absolutely sure that my code works. I think the problem might be that I call a method on a static member in the LogMyException method. Anyhow, when I run the tests one by one, it works everytime. If I run them all at once they sometimes pass, but sometimes they don't. The LogMyException method is a private method and I test if LogMyException gets called as follows:
public void AddKeys(bool resultIsValid) { if (!resultIsValid) { LogMyException(message); } }
I'm absolutely sure that my code works. I think the problem might be that I call a method on a static member in the LogMyException method. Anyhow, when I run the tests one by one, it works everytime. If I run them all at once they sometimes pass, but sometimes they don't. The LogMyException method is a private method and I test if LogMyException gets called as follows:
public void Test() { var called = false; // Initialize test class Mock.NonPublic.Arrange(confStringManager, "LogMyException", ArgExpr.IsAny<string>()).DoInstead(() => called = true);// Do something which makes the class call LogMyExceptionAssert.True(called); }