我在对我编写的行为进行单元测试时遇到问题。行为如下:
NumericTextBoxBehavior : Behavior<TextBox>
{
//handles few events like TextChanged ,PreviewTextInput , PreviewKeyDown , PreviewLostKeyboardFocus
//to give make it accept numeric values only
}
Run Code Online (Sandbox Code Playgroud)
在单元测试相同的同时我编写了这段代码
TextBox textBoxInvoker = new TextBox();
NumericTextBoxBehavior target = new NumericTextBoxBehavior();
System.Windows.Interactivity.Interaction.GetBehaviors(TextBoxInvoker).Add(target);
Run Code Online (Sandbox Code Playgroud)
现在要提出这个事件我必须打电话
textBoxInvoker.RaiseEvent(routedEventArgs)
Run Code Online (Sandbox Code Playgroud)
此路由事件参数又将路由事件作为参数。
请帮助我如何创建模拟 RoutedEventArgs 来引发事件并进一步对行为进行单元测试。
提前致谢。