Has anyone been able to successfully use the unit test methods, which, if necessary, are associated with the System.Windows.Forms.Form class?
I recently worked on a C # winforms application, trying to build it using the MVC framework. This is quite complicated, given that the structure is not actually built with this in mind.
However, it gets even tougher when you drop unit testing into the mix. I am sure my controllers are not related to specific view classes, so I can use stub / mock for unit testing. But a reference to the form class is somewhere inevitable, and these methods need to be tested.
I used Moq because it has some good type safety features and allows you to mock specific types. But, unfortunately, this does not allow me to “expect” calls to methods or properties of a particular type that are neither virtual nor abstract. And since the Form class was not built with a subclass in mind, this is a big problem. I need to be able to make fun of the Form class to prevent the creation of real windows, for example, by “waiting” for ShowDialog.
Thus, I was not able to run any unit tests that interact a lot with subclasses of the form that have my views.
Is there anyone who has successfully tested this type of code? How did you do that?
-, ? , , ? , ?
- , , , , , ?