Microsoft introduced the System.TimeProvider
as a means to provide a testable time provider. It relies on
dependency to provide testability.
Qowaiv's Clock
also provides a testable time provider without relying on dependency injection.
To ensure that both the System.TimeProvider implementation and Qowaiv.Clock.UtcNow()
yield the same behavior, the Qowaiv.Clock.TimeProvider should be used. As an
additional benefit, System.TimeProvider instance does not have to be changed
under test.
var service = new Service(TimeProvider.System);var service = new Service(Qowaiv.Clock.TimeProvider);