我是单元测试的新手。如何将参数传递给下面的函数
OnDefineInDictCompleted
client.DefineInDictCompleted += new EventHandler<DefineInDictCompletedEventArgs>(OnDefineInDictCompleted);
OnDefineInDictCompleted(object sender, DefineInDictCompletedEventArgs e)
答案 0 :(得分:1)
而不是将OnDefineInDictCompleted
定义为使用匿名委托的方法?
var parameterA = 1;
var parameterB = "Foo";
EventHandler<DefineInDictCompletedEventArgs> handler = (s, e) =>
{
//Can access local variables here;
var x = parameterA.ToString() + parameterB;
};
client.DefineInDictCompleted += handler;