I use attached Behaviors to add drag and drop functionality to my code. So far, everything is working fine, but my problem is when I want to test my behavior classes.
For example, one of the behavior classes will look something like this:
public class DroppableContainerBehavior: Behavior<FrameworkElement> { protected override void OnAttached() { base.OnAttached(); AssociatedObject.AllowDrop = true; AssociatedObject.Drop += new DragEventHandler(AssociatedObject_Drop); AssociatedObject.DragOver += new DragEventHandler(AssociatedObject_DragOver); AssociatedObject.DragLeave += new DragEventHandler(AssociatedObject_DragLeave); } private void AssociatedObject_Drop(object sender, DragEventArgs e) { ... } }
Now the problem is when I want to create a unit test for the AssociatedObject_Drop method, I will need to create a DragEventArgs object, but this class is sealed.
I got the impression that I'm doing something wrong. My question is: should I test my behavior classes? The behavior is related to the user interface, and usually it is not worth testing the interface. I'm right? Maybe I need to change the behavior code to make it more verifiable? any ideas?
Thanks for your help!
source share