开发者

Rhino mocks record\play model artefacts

a have some artefacts when using Rhino Mocks

var mocks = new MockRepository();

INotifyMessageSender messageSenderMock; 

NotificationAgent notificatio开发者_JAVA技巧nAgent = null;

var machineID = Guid.NewGuid();
messageSenderMock = mocks.DynamicMock<INotifyMessageSender>();                            
notificationAgent = new NotificationAgent(machineID, messageSenderMock);//in constructor                                 

//notification agent subscribes on messageSenderMock event MessageReceived
using (mocks.Record())
{           
    messageSenderMock.SendRegisterNodeMessage(machineID);          
}
notificationAgent.Start(); // this method should call messageSenderMock.SendRegisterNodeMestod
                             // and it calls this mesthod. i checked in debug mode
messageSenderMock.VerifyAllExpectations();


You are mixing Rhino mock syntaxes. I would use the new AAA syntax. It's much easier.

INotifyMessageSender messageSenderMock = MockRepository.GenerateMock<INotifyMessageSender>();

NotificationAgent notificationAgent = new NotificationAgent(Guid.NewGuid(), messageSenderMock);

notificationAgent.Start();

messageSenderMock.AssertWasCalled(x => x.SendRegisterNodeMessage(machineID)); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜