Okay, bear with me...this is an intersting problem and I am mainly just looking for an explanation for my education. I don't think it is necessarily a "problem" or bug with TypeMock. I'm sure it has to do with my lack of understanding of exactly how Mock objects work.
I am using TypeMock 3.1.0 with Nunit 2.2.7. I am running the tests through TestDriven.net in VS2005.
I have the following setup in my TestFixture
[TestFixture]
public class sqlHelperFixture
{
private Mock exeQueryMock;
[Setup]
public void Setup()
{
exeQueryMock = MockManager.Mock(typeof(SqlHelper), Constructor.Mocked);
}
}
Now I have this test which does _Not_ attempt to make use of this Mock instance.
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ExecuteNonQueryWithNullStrConnException()
{
SqlHelper.ExecuteNonQuery((SqlConnection)null, "ProcedureName", (SqlParameter[])null);
}
When I run the test it fails but then the expected exception is thrown out to the console.
The expected behavior here is that the exception to be caught as expected and the test should pass.
When I removed the declaration at the class level and started using local Mock objects in each of my tests, the above test began working.
Thanks in advance for any explanations.