3
我在單元測試中遇到了問題,我寫了一個行爲。該行爲如下:單元測試文本框行爲
NumericTextBoxBehavior : Behavior<TextBox>
{
//handles few events like TextChanged ,PreviewTextInput , PreviewKeyDown , PreviewLostKeyboardFocus
//to give make it accept numeric values only
}
雖然單元測試我寫了這個代碼
TextBox textBoxInvoker = new TextBox();
NumericTextBoxBehavior target = new NumericTextBoxBehavior();
System.Windows.Interactivity.Interaction.GetBehaviors(TextBoxInvoker).Add(target);
現在提出我要叫
textBoxInvoker.RaiseEvent(routedEventArgs)
此路由事件參數事件一樣轉爲路由事件作爲參數。
請幫助我如何創建mock RoutedEventArgs來提高事件並進一步單元測試的行爲。
在此先感謝。