Hey everyone,
I am trying to do some static mocking. here is my test.
The class TimesheetProcessor uses LaborManager.GetTimesheetLabor() method which I have setup to return a new Collection which by Default would have a count == 0.
However, when I step into this and get into the TimesheetProcessor class where LaborManager.GetTimeSheetLabor() method is called. the variable laborEntries which calls the method I arranged in my test gets set to null instead of a new collection. Please see the timesheet processor code below
Why is this happening?
Have I setup my test incorrectly?
I have JustMock enabled.
Thanks,
-zd
I am trying to do some static mocking. here is my test.
[Test]
public
void
timesheet_processor_tests_just_mock()
{
Mock.SetupStatic(
typeof
(LaborManager));
Mock.Arrange(() => LaborManager.GetTimesheetLabor(DateTime.Now, 1683)).Returns(
new
TimesheetLaborReadOnlyCollection());
var processor =
new
TimesheetProcessor();
processor.ProcessUserTimesheet(DateTime.Now, 1683);
Mock.Assert(() => LaborManager.GetTimesheetLabor(DateTime.Now, 1683), Occurs.AtLeastOnce());
}
The class TimesheetProcessor uses LaborManager.GetTimesheetLabor() method which I have setup to return a new Collection which by Default would have a count == 0.
However, when I step into this and get into the TimesheetProcessor class where LaborManager.GetTimeSheetLabor() method is called. the variable laborEntries which calls the method I arranged in my test gets set to null instead of a new collection. Please see the timesheet processor code below
//Timesheet Processor Class
public
void
ProcessUserTimesheet(DateTime weekEndingDate,
int
userId)
{
TimesheetsCreated =
new
List<
int
>();
TimesheetLaborReadOnlyCollection laborEntries = LaborManager.GetTimesheetLabor(weekEndingDate, userId);
if
(laborEntries.Count > 0)
ProcessTimesheetLaborUser(userId, weekEndingDate, laborEntries);
}
Why is this happening?
Have I setup my test incorrectly?
I have JustMock enabled.
Thanks,
-zd