Mock.Object返回null

时间:2017-08-02 21:18:24

标签: c# .net moq

鉴于以下模拟创作

_mockSlaTimer = new Mock<IMPulse>();
_mockDataService = new Mock<IDataService>();
_mockDialogService = new Mock<IDialogService>();
_mockViewLocator = new Mock<IViewLocator<IPage>>();
_mockInsightsProvider = new Mock<IInsightService>();
_mockNavigationService = new Mock<INavigationService>();

_mockViewLocator.Object属性始终为null

接口定义没什么特别的:

public interface IPage
{
}

public interface IViewLocator<TPageType> where TPageType : IPage
{
    void RegisterViewFor<TViewModelType>(TPageType page) where TViewModelType : IViewModel;
    TPageType ResolveViewFor<TViewModelType>() where TViewModelType : IViewModel;
}

请注意下面的屏幕抓取

enter image description here

为什么object属性会返回null?

0 个答案:

没有答案