我使用的复合WPF(棱镜),我试图单元测试,我的控制器事实上确实订阅复合事件。
我申购代码如下...
//Init Events.
this.eventAggregator.GetEvent<PlantTreeNodeSelectedEvent>().Subscribe(
ShowNodeDetails, ThreadOption.UIThread);
我的单元测试代码如下(我用的起订量为我的模拟框架和统一作为我的DI框架)...
Mock<PlantTreeNodeSelectedEvent> eventBeingListenedTo = new Mock<PlantTreeNodeSelectedEvent>();
eventAggregatorMock.Setup(e => e.GetEvent<PlantTreeNodeSelectedEvent>()).Returns(eventBeingListenedTo.Object);
//Initialize the controller to be tested.
IPlantTreeController controllerToTest = container.Resolve<IPlantTreeController>();
//Verify.
eventBeingListenedTo.Verify(
e => e.Subscribe(It.IsAny<Action<string>>(), ThreadOption.UIThread));
该订阅方法被调用(我用调试器中运行验证),但验证总是失败,“祈求并没有对模拟进行:E => e.Subscribe ......”
任何想法,我做错了什么?