chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I'm calling MockManager.Mock() within a foreach loop to set up expectations for a set number of instances of a particular type, as follows:

foreach (ApplicantType applicant in Applicants)
{
    Mock employmentTypeMock = MockManager.Mock(typeof(EmploymentType), Constructor.Mocked);
    employmentTypeMock.ExpectGet("EmploymentTypeId", new DynamicReturnValue(delegate(object[] parameters, object context) { return new int?(applicant.EmploymentTypeId); }));
}


The problem I'm having is that the tests will pass the majority of times, but occasionally will fail. It appears that the first mock is getting lost somewhere.

How can I go about tracking down the culprit here?
asked by thepuffin (2.4k points)

1 Answer

0 votes
Hi,
The best way to tracking this down is by using the TypeMock Tracer. This will work if you mock one type or if you have a commercial license.
Using the Tracer you will see what instances are being missed. Also check that you Init() before running this test.
answered by scott (32k points)
...