Thursday, September 8, 2011

monkey patching

I paired with Jorge Luna yesterday and during that time we monkey patched an instance of the class for time abstraction that I wrote here like so:

[TestInitialize]

public void TestSetup()

{

   DateService.Now = () =>

   {

      return new DateTime(2011, 9, 8);

   };

}

 

[TestMethod]

public void GetProgramStartDateTest()

{

   var startDate = DateService.Now();

   Assert.AreEqual(new DateTime(2011, 9, 8), startDate);

}

No comments:

Post a Comment