我是新來的嘲笑,而且我很難用UnitTesting解決一個問題。我該如何使用Rhino Mocks來檢查傳遞給方法的值是什麼
說我有這樣的代碼:
public class myClass{
private IDoStuff _doer;
public myClass(IDoStuff doer){
_doer = doer;
}
public void Go(SomeClass object){
//do some crazy stuff to the object
_doer.DoStuff(object) //this method is void too
}
}
好了,我想單元測試Go方法。我不關心_doer對象在獲取它時對對象做了什麼。
但是我確實想要檢查_doer對象收到了什麼。
僞代碼,我想要實現這個:
[Test]
public void MyTest()
{
IDoStuff doer = Mocker.Mock<IDoStuff>();
Guid id = Guid.NewGuid();
//test Go method
new MyClass(doer).Go(new SomeClass(){id = id});
Assert.AreEqual(id,MockingFramework.Method(DoStuff).GetReceived<SomeClass>().id);
}
這可能使用犀牛,如果是這樣,我怎麼實現的呢?
歡呼