Horarium icon indicating copy to clipboard operation
Horarium copied to clipboard

Avoid direct use of DateTime.Now or DateTime.UtcNow

Open asylkhan-azat opened this issue 4 years ago • 0 comments

Introduce new abstraction for providing current time to improve testability and make units more independent of environment system is run on.

public interface ITimeProvider
{
    DateTime Now();
    DateTime UtcNow();
}

Currently, ExecutorJob, RecurrentJobBuilder, and ParameterizedJobBuilder in "Horarium" use DateTime.UtcNow directly without any layer of indirection which makes unit tests depend on the time they were run.

Creating this abstraction will result in more deterministic tests.

asylkhan-azat avatar Dec 27 '21 20:12 asylkhan-azat