Пример #1
0
        public void Bind_ToConstant_Where_Component_Is_Not_Instance_Of_Type_Throws_Exception()
        {
            ComponentContainer container = new ComponentContainer();

            IBar bar = new Bar1();
            IFoo foo = new Foo1(bar);

            container.Bind<IBar>().ToConstant(foo);
        }
Пример #2
0
        public void WithConstructorParameter_Overrides_Specific_Bindings()
        {
            ComponentContainer container = new ComponentContainer();

            Bar1 bar = new Bar1();

            container.Bind<IFoo>().To<Foo1>()
                .AsTransient()
                .WithConstructorParameter("bar", bar);

            container.For<IFoo>().Bind<IBar>().To<Bar2>();

            var obj = container.Resolve<IFoo>();
            Assert.AreSame(bar, ((Foo1)obj).Bar);
        }
Пример #3
0
        public void Bind_To_Constant_Does_Not_Construct_New_Instance()
        {
            ComponentContainer container = new ComponentContainer();

            IBar bar = new Bar1();
            container.Bind<IBar>().ToConstant(bar);

            Foo1 foo = container.Resolve<Foo1>();
            Assert.AreSame(bar, foo.Bar);
        }