(with contributions by Georgi Chkodrov)
Github repo: https://github.com/microsoft/SyslogDecode

What is Syslog?

- it is a kind of log …

No, not this kind. Like this one:


Person waiting and waiting
Person waiting and waiting

Developers always strive to provide 100% automated test coverage for the code they write. However, one particular class of features is quite difficult to test — those that depend on current time, in one way or another. In this post I would like to share a simple and efficient technique that I have been using now for years that provides an elegant solution.

Let’s bring up an example — an expiring token in c#:

public class Token {
DateTime _created;

public Token() {
_created = DateTime.UtcNow;
}

public bool IsValid() {
return DateTime.UtcNow < _created.AddMinutes(20);
}
}

Nothing special, and…

Roman Ivantsov

.NET Developer with 20+ years of experience. Open source: Irony (parsing engine), VITA (.NET ORM), NGraphQL (GraphQL engine). @Microsoft, Cloud Security

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store