I've got a class that has a private member that has for type System.Windows.Forms.Timer. There's also a private method that is being called every time my timer ticks.
- Is it worth testing the method? (since it's private)
- How can I test it? (I know I can have my test class inheriting the class I want to test...)
- Should I be mocking my timer? Because if I have to test a class that uses an internal timer, my tests may take a lot of time to complete, right?
edit:
Actually, the method has a dependency on timing, here's the code:
private void alertTick(object sender, EventArgs e) {
if (getRemainingTime().Seconds <= 0) {
Display.execute(Name, WarningState.Ending, null);
AlertTimer.Stop();
}
else {
var warning = _warnings.First(x => x == getRemainingTime());
if (warning.TotalSeconds > 0)
Display.execute(Name, WarningState.Running, warning);
}
}
As you can see, if the timer is running, it calls Display.execute() with different parameters from when it's ending (when the remaining time equals 0). Would that be a problem of design?