c# - Add Controls to Control.Collection -
i´m trying create new controls (textbox, combobox , checkbox) control.controlcollection, doesn´t work. winform pass controls method, i´m trying write unit test it.
here´s code:
testclass target = new testclass(); control.controlcollection controls = null; checkbox checkbox = new checkbox(); checkbox.name = "somecheckbox"; checkbox.checked = true; combobox combobox = new combobox(); combobox.name = "somecombobox"; checkbox.text = "some text in cb"; textbox count = new textbox(); count.name = "counttextbox"; count.text = "20"; textbox date = new textbox(); date.name = "datenow"; date.text = system.datetime.now.tostring("dd.mm.yyyy"); controls.addrange(new control[] {checkbox, combobox, count, date }); string actual; actual = target.saveeverything(controls); test fails in addrange-row. error did make?
ok, i´m stupid. forgot initilize controls.
control con = new control(); control.controlcollection controls = new control.controlcollection(con); c# winforms unit-testing
No comments:
Post a Comment