You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.
You need it for Unit tests.
Sample: When you create an object you want to fill CreatedAt by the DateTime.UtcNow
The current DateTime is a kind of dependency on the environment.
How to write tests to CreatedAt?
The easiest way - create an IDateTime interface and mock it in tests.
And one more benefit - dependency on the IDateTime is explicit. You can see that this class depends on environment.
You need it for Unit tests.
Sample: When you create an object you want to fill CreatedAt by the DateTime.UtcNow
The current DateTime is a kind of dependency on the environment.
How to write tests to CreatedAt?
The easiest way - create an IDateTime interface and mock it in tests.
And one more benefit - dependency on the IDateTime is explicit. You can see that this class depends on environment.
What's the point of having the IDateTime interface? The implementation MachineDateTime just calls DateTime.Now for the Now property.
The text was updated successfully, but these errors were encountered: