private void SingletoneCreation(MiniocContext context) { IOrange orange = context.Resolve <IOrange>(); Assert.That(orange is BlueOrange); orange.tag = "my_test_orange"; }
public IMyClass Create(IApple apple, IOrange orange) { IMyClass myClass = base.CreateInstance(() => Construction. ForType <IApple>(apple) .AndType <IOrange>(orange) ); return(myClass); }
public void TestResolvedInstanceHasBindingDescriptor() { IDIContext context = ContextHelper.CreateContext(); context.m().Bind <IOrange> (() => new Orange1()); IOrange orange = context.Resolve <IOrange> (); IDIClosedContext ctx = orange as IDIClosedContext; Assert.IsNotNull(ctx.bindingDescriptor); }
public void TestResolveObjectWithInvalidatedContext() { IDIContext context = ContextHelper.CreateContext(); context.m().Bind <IOrange> (() => new Orange1()); IOrange orange = context.Resolve <IOrange> (); IDIClosedContext ctx = orange as IDIClosedContext; Assert.IsNotNull(ctx.descriptor.bindingDescriptor); }
public void TestSingletonPersistance() { MiniocContext context = new MiniocContext(); context.s().Bind <IOrange>(() => new BlueOrange()); SingletoneCreation(context); IOrange orange = context.Resolve <IOrange>(); Assert.AreEqual("my_test_orange", orange.tag); }
public void SingletoneSameContextTest() { MiniocContext context = new MiniocContext(); context.s().Bind <IOrange>(() => new RedOrange()); IOrange orange1 = context.Resolve <IOrange>(); IOrange orange2 = context.Resolve <IOrange>(); Assert.That(orange1 is RedOrange); Assert.That(orange2 is RedOrange); Assert.AreSame(orange1, orange2); }
public void MultipleSameContextTest() { IDIContext context = new MiniocContext(); context.m().Bind <IOrange>(() => new RedOrange()); IOrange orange1 = context.Resolve <IOrange>(); IOrange orange2 = context.Resolve <IOrange>(); Assert.That(orange1 is RedOrange); Assert.That(orange2 is RedOrange); Assert.AreNotSame(orange1, orange2); }
public void Initialize(IOrange orange) { if (!isInitialize) { buttonHandlerList = new Dictionary <int, IButtonHandler>(); _isInitialize = true; this._orange = orange; _isEnable = false; CompleteHide(); if (onInitialize != null) { onInitialize(this, new EventArgs()); } log += string.Format("Initialize()\n{0}\n\n", Utilty.CallStack()); } }
public void SingletoneFactoryDifferentContextTest() { IDIContext context1 = new MiniocContext(); context1.s().Bind <IOrange>(() => new RedOrange()); IDIContext context2 = new MiniocContext(); context2.s().Bind <IOrange>(() => new RedOrange()); IOrange orange1 = context1.Resolve <IOrange>(); IOrange orange2 = context2.Resolve <IOrange>(); Assert.That(orange1 is RedOrange); Assert.That(orange2 is RedOrange); Assert.AreNotSame(orange1, orange2); }
public void Initialize(IOrange orange, params IButtonHandler[] btns) { if (!isInitialize) { buttonHandlerList = new Dictionary <int, IButtonHandler>(); this._orange = orange; _isInitialize = true; InitializeButton(btns); SetEnable(false); if (onInitialize != null) { onInitialize(this, new EventArgs()); } log += string.Format("Initialize()\n{0}\n\n", Utilty.CallStack()); } }
public void SingletoneChainedContextTest() { MiniocContext context1 = new MiniocContext(); context1.s().Bind <IOrange>(() => new RedOrange()); MiniocContext context2 = new MiniocContext(context1); IOrange orange1 = context1.Resolve <IOrange>(); IOrange orange2 = context2.Resolve <IOrange>(); Assert.That(orange1 is RedOrange); Assert.That(orange2 is RedOrange); Assert.AreSame(orange1, orange2); context2.s().Bind <IOrange>(() => new RedOrange()); orange2 = context2.Resolve <IOrange>(); Assert.That(orange2 is RedOrange); Assert.AreNotSame(orange1, orange2); }
public Apple(IOrange orange) { this.orange = orange; }
protected void InjectionMethod(IOrange orange) { this.orange = orange; }
protected void InjectionMethod(IOrange orange, IApple apple) { this.orange = orange; this.apple = apple; }