Skip to content

Instantly share code, notes, and snippets.

@cbilson
Created October 7, 2009 03:42
Show Gist options
  • Save cbilson/203702 to your computer and use it in GitHub Desktop.
Save cbilson/203702 to your computer and use it in GitHub Desktop.
namespace StupidExample {
public class CustomerGateway {
IUnitOfWorkManager work;
public CustomerGateway(IUnitOfWorkManager work) { this.work = work; }
public IEnumerable<Customer> GetNewCustomersSince(DateTime time) {
work.On("CustomerDB", session =>
session.CreateCriteria<Customer>()
.Add(Expression.Gt("EffectiveDate", time))
.List<Customer>());
}
public class when_there_are_new_customers : with_the_customer_database {
Establish context = () => {
work = MockRepository.GenerateStub<IUnitOfWorkManager>();
work.Stub(x => x.On("CustomerDB", Arg.Is.Anything))
.Return(null)
.WhenCalled(invocation => invocation.ReturnValue
= ((Func<ISession,IEnumerable<Customer>>) invocation.Arguments[1])(session));
}
It notices_there_are_new_customers_and_starts_dealing_with_it = () =>
gotNewCustomers.ShouldBeTrue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment