我目前正在尝试让我的一个单元测试正常工作,但有一件事在路上。我有一个名为 AccountingScheduleLookup 的类,它附加了一个只读的 ID 字段。当我尝试模拟对使用此 ID 字段的方法的调用时,它会在该特定代码行上向我抛出一个可爱的 NullReferenceException。这意味着要么没有为其分配 ID,要么没有实例化对象。
但是,当我确实进行了基本实例化时,它仍然给我抛出了异常。关于如何解决这个问题的任何想法?
这是一个代码示例(对于它的价值)
AccountingScheduleLookup = new AccountingSchedule { Description = "Will this work?" }
var calendarPeriods = dal.GetObjects<AccountingScheduleDetail>(
Where.Property("AccountingScheduleID").Is(AccountingScheduleLookup.AccountingScheduleID));