I’ve got a C# project that has most of it’s complex behavior implemented as event handlers for a spreadsheet that the user interacts with.
I’m familiar with testing code, but I’m not sure how to test complex behavior of a spreadsheet (like adding and removing rows or calling 3rd party components when the user changes a cell’s value). Not only is the coded behavior entangled with spreadsheet behavior, but I also can’t get the spreadsheet events to fire when changing its values programmatically. I don’t know what to mock since it’s not really broken into different classes either.
Is there a Selenium for WinForms or some other way to do this?
In case anyone else runs into this, I ended up using something that’s basically the Adapter Pattern or Mediator Pattern depending on how you look at it. Each spreadsheet is wrapped by an adapter that formats the spreadsheet and communicates with the code. The code tells the mediator to display some domain objects and it fills in the appropriate cells and triggers the appropriate events (CellEndEdit, etc). After the user modifies the spreadsheet, the mediator gives the resulting domain objects to the code. Unit tests verify that it can read and write the domain objects correctly as well as trigger the correct events when the code is acting on it. Other tests verify that when the user puts the right data in the right cells, then the resulting domain objects have the correct data. It’s extra work but it’s now possible to make behavior rely on the mediators instead of the spreadsheets.