Last active
May 8, 2017 18:06
-
-
Save bendangelo/a5e97f2ee00bebd52458601471b45f97 to your computer and use it in GitHub Desktop.
Auto substitute helper method for Zenject.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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