Skip to content

Instantly share code, notes, and snippets.

/FormattingService.cs Secret

Created Jun 27, 2016
Embed
What would you like to do?
Testable virtual
public class FormattingService
{
public string Format(string message)
{
return Now + ": " + message;
}
protected virtual DateTime Now => DateTime.Now;
}
internal class TestableFormattingService : FormattingService
{
private readonly DateTime _currentDate;
public TestableFormattingService(DateTime currentDate)
{
_currentDate = currentDate;
}
protected override DateTime Now => _currentDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.