Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 856 Bytes

File metadata and controls

22 lines (18 loc) · 856 Bytes

QW0018: Use Qowaiv.Clock.TimeProvider

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.

Non-compliant

var service = new Service(TimeProvider.System);

Compliant

var service = new Service(Qowaiv.Clock.TimeProvider);