public void TestBindConstructor()
        {
            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();

            b.BindConstructor(GenericType <A> .Class, GenericType <ACons> .Class);
            b.BindConstructor(GenericType <B> .Class, GenericType <BCons> .Class);

            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(B));
        }
Example #2
0
        public void TestBindConstructor()
        {
            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();

            b.BindConstructor <TestExternalConstructors.A, TestExternalConstructors.ACons>();
            b.BindConstructor <TestExternalConstructors.B, TestExternalConstructors.BCons>();

            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(TestExternalConstructors.B));
            TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(TestExternalConstructors.A));
        }
        public void TestSImpleExternalConstructor()
        {
            ICsConfigurationBuilder b = TangFactory.GetTang().NewConfigurationBuilder();

            b.BindConstructor(GenericType <A> .Class, GenericType <ACons> .Class);
            A aRef = (A)TangFactory.GetTang().NewInjector(b.Build()).GetInstance(typeof(A));

            Assert.IsNotNull(aRef);
        }
        public void TestExternalLegacyConstructor()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();

            cb.BindConstructor(GenericType <ExternalConstructorExample.Legacy> .Class, GenericType <ExternalConstructorExample.LegacyWrapper> .Class);
            IInjector i = tang.NewInjector(cb.Build());

            i.BindVolatileInstance(GenericType <int> .Class, 42);
            i.BindVolatileInstance(GenericType <string> .Class, "The meaning of life is ");
            ExternalConstructorExample.Legacy l = i.GetInstance <ExternalConstructorExample.Legacy>();
            Assert.AreEqual(42, l.X);
            Assert.AreEqual("The meaning of life is ", l.Y);
        }