Scott, thank you for replying.
Performing my unit test with the JITA attibute I receive the very useful "The server threw an exception" message.
Tracer does show that my objects are mocked.
To help I have included the code in question:
This is the COM+ class marked with the JITA attibute. Removing it, and the test (see later) works.
[JustInTimeActivation(true)]
[Guid("932588BE-BBB6-4d9c-AD68-7155E6B6DB6B")]
public class SimpleDA : ServicedComponent
{
public SimpleDA()
{
}
public bool Execute()
{
ContextUtil.DeactivateOnReturn = true;
return true;
}
}
The data access class is called by the business object:
internal class SimpleBO
{
public SimpleBO()
{
}
public bool Execute()
{
bool isExecuted = false;
SimpleDA dataAccess = new SimpleDA();
try
{
isExecuted = dataAccess.Execute();
}
finally
{
//ServicedComponent.DisposeObject(dataAccess);
}
return isExecuted;
}
}
Finally, the test:
[Test]
public void TestExecute()
{
MockManager.Init();
Mock mockSimpleDA = MockManager.Mock(typeof(SimpleDA));
mockSimpleDA.ExpectAndReturn("Execute", false);
SimpleBO businessObject = new SimpleBO();
bool isExecuted = businessObject.Execute();
Assert.IsFalse(isExecuted, "Incorrect");
mockSimpleDA.Verify();
}
Regards,
Chris.