1
我在寫單元測試用例。我正在使用nunit和rhino mock。模型顯示null
方法這是我測試是
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);
}
和測試用例寫得
[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
}
我已經做了
private ILoanModelAssembler loanAssembler;
loanAssembler = TestUtility.DynamicMock<ILoanModelAssembler>();
,但仍然在這裏模型是空?有什麼方法可以在測試方法中糾正它?
*,其中*是空嗎? –
你的代碼使用匯編程序,你的單元測試使用loanAssembler ... –
嘿安德拉斯佐爾坦,我調試模型,然後它會顯示空。 – Ninad