I'm attempting to create a WPF MVVM View Model that has a dependency injected System.Timing.Timer
, and wish to test the view model with Moq.
I wrote a thin wrapper around the Timer
class that has a interface ITimer
, but am unsure of the best way to really test the timer's contribution to the class. Is there a good way to 'force' a mock elapsed event? Does somebody else have a better technique?
You should test your code in isolation. Otherwise you don't know whether your code behaves as expected, or there is some side-effect in external dependency. Thus creating mockable wrappers for external resources (configuration files, timers, etc) is the only way you can separate your SUT from external code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With