Skip to content

Instantly share code, notes, and snippets.

@carlin-q-scott
Created February 17, 2017 23:42
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 carlin-q-scott/705a69a336d84271455a80bdbb55141f to your computer and use it in GitHub Desktop.
Save carlin-q-scott/705a69a336d84271455a80bdbb55141f to your computer and use it in GitHub Desktop.
/// <summary>
/// Note that if this is the end of your assertion chain then append () or .Invoke() to the end
/// </summary>
/// <param name="action"></param>
/// <param name="time"></param>
/// <param name="precision"></param>
/// <returns></returns>
public static Action ShouldTakeCloseTo(this Action action, TimeSpan time)
{
return () =>
{
var startTime = DateTime.Now;
action();
TimeSpan executionTimespan = DateTime.Now - startTime;
executionTimespan.Should().BeCloseTo(time);
};
}
public static Action And(this Action action)
{
return action;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment