views:

69

answers:

1

Visual Studio (2005 Professional), Windows Forms application : I've got a form which contains 8 tabs, each of them containing a few dozen of controls. Each of them is bound to an element of a typed dataset. This great except for the fact that data binding errors can only be found at runtime, and are often silent.

Typical case : I have to rename a column in a table of the dataset, and I forget to update the data binding information for one control that is linked to this column...

Do you know of a way to :

  • detect unbound controls in a form ?
  • detect controls that are bound to invalid (non existent) data ?
+2  A: 

You can use unit tests. In one of the test you will create instance of form, set some sample data and then iterate all controls and check for databinding. If is bounded to data, try to read/write value. If you get exception, you know where si bug.

TcKs
I guess I'm not used to UI unit testing. Yet...
Mac