public void Test_Multiple_Values_Are_Able_To_Be_Injected() { Sample s = new Sample(); const int i = 10; IBinding <ISample> sampleBinding = from value in LindiMethods.Bind <ISample>() select s; IBinding <int> intBinding = from value in LindiMethods.Bind <int>() select i; IInjectValuesInto <INeedSampleAndInt> injector = LindiMethods.Inject() .Where(value => LindiMethods.InjectedInto(value) as INeedSampleAndInt) .Select(value => { value.Sample = sampleBinding.Resolve(); value.Int = intBinding.Resolve(); }); NeedSample needsSample = new NeedSample(); injector.Inject(needsSample); Assert.Same(s, needsSample.Sample); Assert.Equal(i, needsSample.Int); }
public void Test_Where_Without_Select_Returns_Incomplete_Injection() { Sample s = new Sample(); IInjectValuesInto <INeedSample> binding = LindiMethods.Inject() .Where(v => LindiMethods.InjectedInto(v) as INeedSample); NeedSample needSample = new NeedSample(); Assert.Throws <BindingResolutionException>(() => { binding.Inject(needSample); }); }
public void Test_Where_Is_Able_To_Inject_Values_Into_Type() { Sample s = new Sample(); IBinding <ISample> sampleBinding = from value in LindiMethods.Bind <ISample>() select s; IInjectValuesInto <INeedSample> binding = LindiMethods.Inject() .Where(v => LindiMethods.InjectedInto(v) as INeedSample) .Select(value => { value.Sample = sampleBinding.Resolve(); }); NeedSample needSample = new NeedSample(); binding.Inject(needSample); Assert.Same(s, needSample.Sample); }