Unit test WPF Bindings

后端 未结 5 568
萌比男神i
萌比男神i 2021-01-04 11:08

I am trying to unit test my WPF databindings using the test suit provided by Microsoft Team System. I would like to be able to test the bindings without showing the window

5条回答
  •  Happy的楠姐
    2021-01-04 11:41

    Shane, if what you're really worried about is a binding breaking silently, you should look at redirecting the binding traces to somewhere you can examine. I'd start here:

    http://blogs.msdn.com/mikehillberg/archive/2006/09/14/WpfTraceSources.aspx

    Other than that, I agree with Gishu that bindings aren't good candidates for unit testing, mainly due to the automagic going on that Gishu mentioned in the "Epilogue". Instead focus on making sure the underlying class behaves correctly.

    Note, too, that you can get even more robust traces using the PresentationTraceSources class:

    http://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.aspx

    Hope that helps!

提交回复
热议问题