Q:

Mock for RX -constraction which process events from mouse

I have next expression
 private IObservable<Point> GetLeftMouseDown()
    {
        return from pattern in Observable.FromEventPattern<MouseButtonEventArgs>(_element, "MouseDown")
            where pattern.EventArgs.ChangedButton == MouseButton.Left
            select pattern.EventArgs.GetPosition(_element);
    }

Is possible to mock source of events for tests? What I sholud do with GetPositionMethod wich call system functions and it isn't virtual?
Thanks

A:

You don't need to test your GetLeftMouseButtonDown function in a unit test. What are you actually testing? You're testing Linq, Rx, and the EventArgs object, none of which you wrote. I'd probably write a quick interactive integration style test that ensures I am in fact getting the left button clicks, and call it good.
What you want to do in testing is to pass in an IObservable<Point> into the method under test. You can then pass in an IObservable that you can put values into. I'd probably just use a Subject object, no need to write your own mock implementation.
Then shoot whatever stream of values into it you want to test against, and observe the results in your tests. 

