As already mentioned, unit tests usually target application logic public methods, not UI related methods.
If you really insist on testing your method, you should follow these steps:
1) Setup phase - this a phase to initialize the context of your tests. In you case initializing and opening of the form containing the combo boxes
2) Tear down phase - this is a phase to leave the things as if your tests never ran. E.g. close and dispose in your form
3) Actual test - get some combo boxes instances, have them enabled, call your method, check that all checkboxes are disabled
Some (pseudo-)-code using NUnit framework attributes (not tested, it is just to get you started):
[TestFixture]
public class YourFormTests
{
private Form frm;
[OneTimeSetUp]
public void SetUp()
{
frm = new Form();
frm.Show();
}
[OneTimeSetup]
public void TearDown()
{
frm?.Close();
frm?.Dispose();
}
[Test]
public void TestComboDisabled()
{
frm.cmbSomeName.Enabled = true;
frm.comboDisable();
Assert.IsFalse(frm.cmbSomeName.Enabled, "Combo is not disabled");
}
}
This assumes your method is public and also tested combo box. Theoretically, you can dynamically invoke a private method, but this is really ugly and not recommended (method rename produced a TargetInvocationException
instead of compilation error).
This should provide a basic idea on the unit testing creation, but you should really read the basics.