I am writting unit test cases. I am using nunit and rhino mock.
Method which is i am testing is
public ActionResult Details()
{
EmployeeDTO employee = this.EmployeeService.GetLoggedInEmployee();
EmployeeModel model = assembler.ToEmployeeModel(employee);
model.Title = GetEmployeeNameTitle(employee);
model.Controller = "LoanOfficer";
model.SelectedTab = MainNavTabs.LoanOfficerDetails;
return View(model);
}
And test case written is
[Test]
public void TestDetails()
{
EmployeeDTO employee = new EmployeeDTO();
EmployeeService.Stub(a => a.GetLoggedInEmployee()).Return(employee);
EmployeeModel model = new EmployeeModel{ Title = UtilityTests.Title, };
assembler.Stub(b => b.ToEmployeeModel(employee)).Return(model);
controller.Details();
// Assert
}
I have done
private ILoanModelAssembler loanAssembler;
loanAssembler = TestUtility.DynamicMock<ILoanModelAssembler>();
but still here model is null ? Is there is any way to correct it in test method?