Skip to content

Instantly share code, notes, and snippets.

@blazey
Last active August 29, 2015 14:23
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 blazey/9c7cc7b6bcb276142d5e to your computer and use it in GitHub Desktop.
Save blazey/9c7cc7b6bcb276142d5e to your computer and use it in GitHub Desktop.
Enabling in-memory integration tests by swapping out components in tests, post normal registration of components in container
_bootstrap = new Bootstrap();
_bootstrap.AddFacility<TestSubstituteFacility>(config =>
{
config.WithContainer(_bootstrap.Container)
.Substitute<IDataLakeWriter>(sub => sub.Instance(_dataLakeWriterMockery.Mock))
.Substitute<ICollectorAgentDispatcher>(sub => sub.Stub())
.Substitute<IBackgroundJobClient>(sub => sub.Stub())
.Substitute<ISchedulesReportWriter>(sub => sub.Stub())
.Substitute<IRepository<Resource>>(sub => sub.Instance(() =>
{
var store = Wireup.Init().UsingInMemoryPersistence().Build();
return new Repository<Resource>(Resource.New, new UnitOfWork(), store);
}));
});
_controller = _bootstrap.Container.Resolve<IController>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment