public static Game NewGame(IBindingContext context) { WorldLogicCoordinateTransform transformer = new WorldLogicCoordinateTransform(0.32f,10,10); var boardView = context.Get<BoardView> (InnerBindingNames.Empty,10,10,transformer); return new Game(boardView); }
public void NamedBindingDifferentNameError() { IBindingContext context = TestsFactory.BindingContext(); context.Bind <int>("foo").To(() => 45); Assert.Throws <BindingNotFound>(() => context.Get <int>("notFoo")); }
public void BindingSimpleInt() { IBindingContext context = TestsFactory.BindingContext(); int expected = 45; context.Bind <int>().To(() => expected); Assert.AreEqual(context.Get <int>(), expected); }
public void OneArgumentBindingError() { //Requires a string to get the int binging IBindingContext context = TestsFactory.BindingContext(); context.Bind <int>().With <string>().To((value) => 45); Assert.Throws <BindingNotFound>(() => context.Get <int>()); }
public void UnsafeNamedBinding() { IBindingContext context = TestsFactory.BindingContext(); System.Func <int> func = () => 45; IBinding binding = new Binding(func); context.Unsafe.Bind("name", typeof(int)).To(binding); Assert.AreEqual(context.Get <int>("name"), 45); }
void Start() { DontDestroyOnLoad (gameObject); var bindingFinder = new ReflectiveBindingFinder (GetType ().Assembly); m_masterContext = new ReflectiveBindingContextFactory (bindingFinder).CreateContext(); m_masterContext.Get<Game> (); }
public void NamedBindingInt() { IBindingContext context = TestsFactory.BindingContext(); int expected = 45; string bindingName = "foo"; context.Bind <int>(bindingName).To(() => expected); Assert.AreEqual(context.Get <int>(bindingName), expected); }
public void OneArgumentBinding() { IBindingContext context = TestsFactory.BindingContext(); context.Bind <int>().With <string>().To((strParam) => 45); context.Bind <string>().To(() => "uhul"); int ret = context.Get <int>(); Assert.AreEqual(ret, 45); }
public void TwoArgumentBinding() { IBindingContext context = TestsFactory.BindingContext(); context.Bind <int>().With <string>().With <float>().To((str, flt) => 45); context.Bind <string>().To(() => "uhul"); context.Bind <float>().To(() => 3.0f); int ret = context.Get <int>(); Assert.AreEqual(ret, 45); }
public void OneCorrectArgumentBinding() { IBindingContext context = TestsFactory.BindingContext(); string parameter = ""; context.Bind <int>().With <string>().To((value) => { parameter = value; return(45); }); context.Bind <string>().To(() => "uhul"); context.Get <int>(); Assert.AreEqual(parameter, "uhul"); }
public void OneArgumentNamedBinding() { IBindingContext context = TestsFactory.BindingContext(); int expected = 45; context.Bind <int>().With <string>("MyText").To((value) => expected); context.Bind <string>("MyText").To(() => "uhul"); int ret = context.Get <int>(); Assert.AreEqual(ret, expected); }
// Use this for initialization void Start() { var assembly = Assembly.GetAssembly(typeof(Bootstrap)); var provider = new EasyInject.Engine.Runtime.ReflectiveBindingFinder(true, new Assembly[] { assembly }); var factory = new EasyInject.Engine.Runtime.ReflectiveBindingContextFactory(provider); m_context = factory.CreateContext(); //var up = UniRx.Observable.EveryUpdate().Where((u)=> Input.GetKeyDown(KeyCode.KeypadPlus)).Select((u)=> true); //var down = UniRx.Observable.EveryUpdate().Where((u) => Input.GetKeyDown(KeyCode.KeypadMinus)).Select((u) => false); // m_context.Get<Turret>(); m_context.Get <Turret>(InnerBindingNames.Empty, Vector2.zero); }
public void UnsafePartialBinding() { IBindingContext context = TestsFactory.BindingContext(); IBindingRequirement requirement = BindingRequirements.Instance.With <float>(); context.Bind <float>().To(() => 0.1f); int extra = -1; System.Func <float, int, int> func = (bindinded, nonBinded) => { extra = nonBinded; return(45); }; IBinding binding = new Binding(func, requirement); context.Unsafe.Bind(typeof(int)).To(binding); context.Get <int>(InnerBindingNames.Empty, 32); Assert.AreEqual(32, extra); }
public void BindingSimpleIntError() { IBindingContext context = TestsFactory.BindingContext(); Assert.Throws <BindingNotFound>(() => context.Get <int>()); }
static public T Get <T>(this IBindingContext me, object name, params object[] extras) { return(me.Get <T>(new BindingName(name), extras)); }
public void NamedBindingIntError() { IBindingContext context = TestsFactory.BindingContext(); Assert.Throws <BindingNotFound>(() => context.Get <int>("foo")); }
public T TypedGet <T> (IBindingContext context) { return(context.Get <T>()); }
public T TypedInterfaceGet <T> (IBindingContext context) where T : ITestInterface { return(context.Get <T>()); }