0
[Test]
public void OnActionExecuting_Always_Call_CheckStatisticActionAuthorization()
{
//Arrange
var _ActionExecutingContext = GetActionExecutingContext();
var _StatisticController = MockRepository.GenerateStub<StatisticsController>();
_StatisticController.DataContext = fDataContext;
//Act
_StatisticController.OnActionExecuting(_ActionExecutingContext, false);
//Assert
_StatisticController.AssertWasCalled(aStatisticController =>
aStatisticController.CheckStatisticActionAuthorization(_ActionExecutingContext));
}
我一直從CheckStatisticActionAuthorization獲取NullReferenceException,StatisticController.DataContext爲null。問題是什麼?謝謝。使用Rhino Mock進行單元測試
見Rhino Mocks Properties哪裏'fDataContext'從何而來?你沒有在你提供的樣本中的任何地方創建它。 –
'StatisticsController'的相關實現細節是什麼? – harlam357