Skip to content

Instantly share code, notes, and snippets.

@jeremydmiller
Created September 28, 2017 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremydmiller/9a89280b37694ba382d4be52aa807086 to your computer and use it in GitHub Desktop.
Save jeremydmiller/9a89280b37694ba382d4be52aa807086 to your computer and use it in GitHub Desktop.
Push, Don't Pull
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