Created
September 28, 2017 21:08
-
-
Save jeremydmiller/9a89280b37694ba382d4be52aa807086 to your computer and use it in GitHub Desktop.
Push, Don't Pull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography.X509Certificates; | |
namespace BlueMilk.Tests | |
{ | |
public class WorkItem | |
{ | |
public DateTime Started { get; set; } | |
} | |
public interface IClock | |
{ | |
DateTime Now(); | |
} | |
public class Clock : IClock | |
{ | |
public DateTime Now() | |
{ | |
return DateTime.UtcNow; | |
} | |
} | |
public class MockedWorkItemProcessor | |
{ | |
private readonly IClock _clock; | |
public MockedWorkItemProcessor(IClock clock) | |
{ | |
_clock = clock; | |
} | |
public void CheckItem(WorkItem item) | |
{ | |
if (_clock.Now().Subtract(item.Started).Days > 5) | |
{ | |
// yell at the developer | |
} | |
} | |
} | |
public class PushBasedWorkItemProcessor | |
{ | |
public void CheckItem(WorkItem item) | |
{ | |
CheckItem(item, DateTime.UtcNow); | |
} | |
private void CheckItem(WorkItem item, DateTime utcNow) | |
{ | |
if (utcNow.Subtract(item.Started).Days > 5) | |
{ | |
// yell at the developer | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment