5
中的代表事件,我想提出一個委託事件。我該怎麼做呢?在我的moq設置中提升Moq
要進行測試:
public class SomeClassToBeTested
{
public void SomeMethodToTest()
{
var event = new ThreadStart(someOtherClass.SomeMethod);
someOtherClass.SomeDelegate += new SomeOtherClass.someDelegate(TriggerMethod);
}
public void TriggerMethod()
{
// do something
}
}
測試類:
[Test]
public void SomeTest()
{
this.moqSomeOtherClass.Setup(fd => fd.SomeMethod())
.Raises(fd => // trigger delgate);
}