Skip to content

Instantly share code, notes, and snippets.

@DarinMacRae
Created March 20, 2013 19:36
Show Gist options
  • Save DarinMacRae/5207761 to your computer and use it in GitHub Desktop.
Save DarinMacRae/5207761 to your computer and use it in GitHub Desktop.
This is a super cool way to specify tests, IMO!
Establish context = () =>
{
persistence.Setup(x => x.Initialize());
persistence.Setup(x => x.GetUndispatchedCommits()).Returns(commits);
dispatcher.Setup(x => x.Dispatch(commits.First()));
dispatcher.Setup(x => x.Dispatch(commits.Last()));
};
Because of = () =>
new AsynchronousDispatchScheduler(dispatcher.Object, persistence.Object);
It should_take_a_few_milliseconds_for_the_other_thread_to_execute = () =>
Thread.Sleep(25); // just a precaution because we're doing async tests
It should_initialize_the_persistence_engine = () =>
persistence.Verify(x => x.Initialize(), Times.Once());
It should_get_the_set_of_undispatched_commits = () =>
persistence.Verify(x => x.GetUndispatchedCommits(), Times.Once());
It should_provide_the_commits_to_the_dispatcher = () =>
dispatcher.VerifyAll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment