Skip to content

Instantly share code, notes, and snippets.

@bendangelo
Last active May 8, 2017 18:06
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 bendangelo/a5e97f2ee00bebd52458601471b45f97 to your computer and use it in GitHub Desktop.
Save bendangelo/a5e97f2ee00bebd52458601471b45f97 to your computer and use it in GitHub Desktop.
Auto substitute helper method for Zenject.
using UnityEngine;
using System.Collections;
using Zenject;
using NSubstitute;
/*
Usage:
Container.Bind<IPath>().FromSub<IPath>();
Container.Bind<IPath>().FromSub();
*/
namespace Zenject
{
public static class ZenjectSubstitiuteExtensions
{
public static ScopeConditionCopyNonLazyBinder FromSub<TContract>(this FromBinderGeneric<TContract> binder)
where TContract : class
{
return binder.FromInstance(Substitute.For<TContract>());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment