Skip to content

Avoid direct use of DateTime.Now or DateTime.UtcNow #48

Description

@asylkhan-azat

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions