public void TestResolve() { Container.Bind <Foo>().AsSingle().NonLazy(); Container.Bind <Bar>().AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>()); }
public void TestOptional1() { Container.Bind <Bar>().AsSingle(); Container.Bind <Qux>().AsSingle(); Assert.IsNotNull(Container.Resolve <Qux>().Bar.Value); }
public void TestInstallerSelfTransient() { Container.Bind <Foo>().FromSubContainerResolve().ByInstance( CreateFooSubContainer()).AsTransient().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>().Bar); }
public void TestInstallerSelfSingle() { Container.Bind <Foo>().FromSubContainerResolve() .ByInstanceGetter(ctx => CreateFooSubContainer()).AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>().Bar); }
public void TestStringIdentifiers2() { Container.Bind <Foo>().WithId("asdf").AsTransient(); Container.Bind <Test0>().AsTransient(); Assert.IsNotNull(Container.Resolve <Test0>()); }
public void TestIntIdentifiers3() { Container.Bind <Foo>().WithId(5).AsTransient(); Container.Bind <Test1>().AsTransient(); Assert.IsNotNull(Container.Resolve <Test1>()); }
public void TestMethodConcreteCached() { Container.Bind <IFoo>().To <Foo>() .FromSubContainerResolve().ByMethod(InstallFooFacade).AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <IFoo>().Bar); }
public void TestEnumIdentifiers3() { Container.Bind <Foo>().WithId(Things.Thing1).AsTransient(); Container.Bind <Test2>().AsTransient(); Assert.IsNotNull(Container.Resolve <Test2>()); }
public void TestConcreteTransient2() { Container.Bind <IFoo>().To <Foo>().AsTransient().NonLazy(); Assert.IsNotNull(Container.Resolve <IFoo>()); Assert.IsNotEqual(Container.Resolve <IFoo>(), Container.Resolve <IFoo>()); }
public void TestInstallerSelfIdentifiers() { Container.Bind <Gorp>().FromSubContainerResolve("gorp") .ByInstanceGetter(ctx => CreateFooSubContainer()).AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Gorp>()); }
public void TestSelfTransient() { Container.Bind <Foo>().AsTransient().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>()); Assert.IsNotEqual(Container.Resolve <Foo>(), Container.Resolve <Foo>()); }
public void TestSelfCached() { Container.Bind <Foo>().AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>()); Assert.IsEqual(Container.Resolve <Foo>(), Container.Resolve <Foo>()); }
public void TestSelfSingleExplicit() { Container.Bind <Foo>().ToSelf().FromNew().AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>()); Assert.IsEqual(Container.Resolve <Foo>(), Container.Resolve <Foo>()); }
public void TestMultipleWithOneTagged() { Container.Bind <Bar>().AsSingle().NonLazy(); Container.Bind <Qux>().AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Qux>()); }
public void TestConcreteUntyped() { Container.BindFactory <IFoo, IFooFactory>().To(typeof(Foo)).NonLazy(); Assert.IsNotNull(Container.Resolve <IFooFactory>().Create()); Assert.That(Container.Resolve <IFooFactory>().Create() is Foo); }
public void TestPostInject() { Container.Bind <Foo2>().AsSingle(); Container.Bind <Bar2>().AsSingle(); Assert.IsNotNull(Container.Resolve <Foo2>()); Assert.IsNotNull(Container.Resolve <Bar2>()); }
public void TestTransient() { Container.Bind <Foo>().AsSingle(); Container.Bind <Bar>().FromResolveGetter <Foo>(x => x.Bar); Assert.IsNotNull(Container.Resolve <Bar>()); Assert.IsEqual(Container.Resolve <Bar>(), Container.Resolve <Foo>().Bar); }
public void TestField() { Container.Bind <Foo3>().AsSingle(); Container.Bind <Bar3>().AsSingle(); Assert.IsNotNull(Container.Resolve <Foo3>().Bar); Assert.IsNotNull(Container.Resolve <Bar3>().Foo); }
public void Test1() { Container.BindIFactory <Foo>(); var factory = Container.Resolve <IFactory <Foo> >(); Assert.IsNotNull(factory.Create()); }
public void Test4() { // This case is more lenient and just ignores invalid bindings Container.Bind(typeof(IFoo), typeof(IBar)).To(typeof(Foo), typeof(Bar)).AsCached(); Assert.IsNotNull(Container.Resolve <IFoo>()); Assert.IsNotNull(Container.Resolve <IBar>()); }
public void TestSelf() { Container.Bind <Foo>().AsSingle().NonLazy(); Container.BindFactory <Bar, Bar.Factory>().FromResolveGetter <Foo>(x => x.Bar).NonLazy(); Assert.IsNotNull(Container.Resolve <Bar.Factory>().Create()); Assert.IsEqual(Container.Resolve <Bar.Factory>().Create(), Container.Resolve <Foo>().Bar); }
public void Init() { Assert.That(!HasInitialized); Assert.IsNotNull(test1); Assert.IsNotNull(test0); Assert.IsNotNull(_test2); HasInitialized = true; }
public void TestAllInterfacesAndSelf() { Container.BindInterfacesAndSelfTo <Foo>().AsSingle().NonLazy(); Assert.IsNotNull(Container.Resolve <Foo>()); Assert.IsNotNull(Container.Resolve <IFoo>()); Assert.IsNotNull(Container.Resolve <IQux>()); }
public void TestSuccessFieldInjectionEnum() { Container.Bind <Test4>().AsTransient().NonLazy(); Container.Bind <Test0>().FromInstance(new Test0()).NonLazy(); Container.Bind <Test0>().WithId("TestValue3").FromInstance(new Test0()).NonLazy(); Assert.IsNotNull(Container.Resolve <Test4>()); }
public void TestInstallerSelfSingle() { Container.Bind <Foo>().FromSubContainerResolve().ByInstaller <FooInstaller>().AsSingle().NonLazy(); var foo = Container.Resolve <Foo>(); Assert.IsNotNull(foo.Bar); Assert.IsEqual(foo, Container.Resolve <Foo>()); }
public void TestConcrete() { Container.BindFactory <string, IFoo, IFooFactory>().To <Foo>().NonLazy(); var ifoo = Container.Resolve <IFooFactory>().Create("asdf"); Assert.IsNotNull(ifoo); Assert.IsEqual(((Foo)ifoo).Value, "asdf"); }
public void TestMethodSelfSingle() { Container.Bind <Foo>().FromSubContainerResolve().ByMethod(InstallFooFacade).AsSingle().NonLazy(); var foo = Container.Resolve <Foo>(); Assert.IsNotNull(foo.Bar); Assert.IsEqual(foo, Container.Resolve <Foo>()); }
public void TestConcrete() { Container.BindFactory <string, int, string, float, int, IFoo, IFooFactory>().To <Foo>().NonLazy(); var ifoo = Container.Resolve <IFooFactory>().Create("asdf", 2, "a", 4.2f, 6); Assert.IsNotNull(ifoo); Assert.IsEqual(((Foo)ifoo).P1, "asdf"); }
public void TestSuccessFieldInjectionString() { Container.Bind <Test1>().AsTransient().NonLazy(); Container.Bind <Test2>().AsTransient().NonLazy(); Container.Bind <Test0>().FromInstance(new Test0()).NonLazy(); Container.Bind <Test0>().WithId("foo").FromInstance(new Test0()).NonLazy(); Assert.IsNotNull(Container.Resolve <Test2>()); }
public void TestParent1() { var rootContainer = new DiContainer(); var sub1 = rootContainer.CreateSubContainer(); rootContainer.Bind <Test0>().AsSingle(); sub1.Bind <Test2>().AsSingle(); Assert.IsNotNull(sub1.Resolve <Test2>()); }