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 not sure if these problems are related, but they appear together, so I'll post them together.

I have a natural mock setup. The recorded mocks look like this:
            MockManager.Init();

            List<MessageInfo> noMessages = new List<MessageInfo>();
            List<TimesheetComments> noComments = new List<TimesheetComments>();
            Timesheet timesheet1 = timesheets[0]; // previously initialized
            Timesheet timesheet2 = timesheets[1];
            Timesheet timesheet3 = timesheets[2];
            PayPeriod payPeriod1 =
                PayPeriod.GetInstance("run1", DateTime.Now.AddDays(-28), DateTime.Now.AddDays(-35), PayRunStatus.Open, null, DateTime.Now.AddDays(-15), "USER", DateTime.Now);
            PayPeriod payPeriod2 =
                PayPeriod.GetInstance("run2", DateTime.Now.AddDays(-14), DateTime.Now.AddDays(-27), PayRunStatus.Open, null, DateTime.Now.AddDays(-1), "USER2", DateTime.Now);
            PayPeriodCollection collection = new PayPeriodCollection();
            collection.AddRange(new PayPeriod[] { payPeriod1, payPeriod2 });

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                Validator.Validate(null, null);
                recorder.Return(noMessages).RepeatAlways();

                TimesheetCommentDataStore commentDataStore;
                TimesheetDataStore dataStore;

                // Validate the timesheets
                dataStore = new TimesheetDataStore();
                dataStore.GetTimesheet(DateTime.Now, null, null, false);
                recorder.Return(timesheet1);

                commentDataStore = new TimesheetCommentDataStore();
                commentDataStore.GetCommentsForTimesheet(null);
                recorder.Return(noComments);

                dataStore = new TimesheetDataStore();
                dataStore.GetTimesheet(DateTime.Now, null, null, false);
                recorder.Return(timesheet2);

                commentDataStore = new TimesheetCommentDataStore();
                commentDataStore.GetCommentsForTimesheet(null);
                recorder.Return(noComments);

                dataStore = new TimesheetDataStore();
                dataStore.GetTimesheet(DateTime.Now, null, null, false);
                recorder.Return(timesheet3);

                commentDataStore = new TimesheetCommentDataStore();
                commentDataStore.GetCommentsForTimesheet(null);
                recorder.Return(noComments);
            }


I also have a few reflective mocks set up afterwards.

When I trace the code through TypeMock, it seems to think that it needs to mock the "Timesheet" type 3 times once the using block has completed. It doesn't seem like that should be happening within the using() block, yet I don't set up mocks anywhere else.

I'm also getting this exception, which has appeared with this test failing:
System.TypeLoadException: Could not load type 'System.Nullable`1' from assembly 'TimeEntryClient, Version=0.2007.4.13, Culture=neutral, PublicKeyToken=null'.
   at Corporate.TimeEntry.Client.UploadTimesheetsForm.AttemptEnumeratorMoveNext(IEnumerator enumerator)
   at Corporate.TimeEntry.Client.UploadTimesheetsForm.validationBackgroundWorker_DoWork(Object sender, DoWorkEventArgs e) in C:Documents and SettingscedpjjoMy DocumentsVisual Studio 2005ProjectsTimeEntryTimeEntryClientUploadTimesheetsForm.cs:line 261
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)


I believe this is related to the erroneous mocks of Timesheet.

This has happened in v4.0.3. I'm using VS2005.
asked by jeffozvold (1.4k points)

5 Answers

0 votes
I backed down to 3.6.1 and I have the same problem.
answered by jeffozvold (1.4k points)
0 votes
If I run the test in debug mode, without breakpoints, the extra mocks of Timesheet do not occur and the exception does not either.

I am running on a dual-core laptop.
answered by jeffozvold (1.4k points)
0 votes
Hi
Can you please send me the the Tracer log and TypeMock logs?
I will send my address off line.
answered by ohad (35.5k points)
0 votes
I have emailed you the trace logs. Here is how it shows up in the Tracer window:

TypeMock Initialized (1)
Always Expect Corporate.TimeEntry.Validation.Validator.Validate()
Always Expect Corporate.TimeEntry.Data.TimesheetDataStore..ctor()
Always Expect Corporate.TimeEntry.Common.Timesheet..ctor()
Always Expect Corporate.TimeEntry.Common.Timesheet..cctor()
Corporate.TimeEntry.Common.Timesheet..ctor() called
Expect Corporate.TimeEntry.Data.TimesheetDataStore.GetTimesheet() 1 Time

... interesting ...
answered by jeffozvold (1.4k points)
0 votes
Ohad told me that running with code coverage is part of the problem. I verified that running the test normally with code coverage disabled is an acceptable temporary workaround.

However, I'm still waiting for a fix.
answered by jeffozvold (1.4k points)
...