Esempio n. 1
0
        public void TestTwoNamedStringArgsBindVolatile()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
            TwoNamedStringArgs      a  = tang.NewInjector(cb.Build()).GetInstance <TwoNamedStringArgs>();

            Assert.AreEqual("defaultA", a.a);
            Assert.AreEqual("defaultB", a.b);
            IInjector i = tang.NewInjector(cb.Build());

            i.BindVolatileParameter(GenericType <TwoNamedStringArgs.A> .Class, "not defaultA");
            i.BindVolatileParameter(GenericType <TwoNamedStringArgs.B> .Class, "not defaultB");
            Assert.AreEqual("not defaultA",
                            i.GetInstance <TwoNamedStringArgs>().a);
            Assert.AreEqual("not defaultB",
                            i.GetInstance <TwoNamedStringArgs>().b);
        }
Esempio n. 2
0
        public void TestTwoNamedStringArgsReBindVolatileFail()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
            TwoNamedStringArgs      a  = tang.NewInjector(cb.Build()).GetInstance <TwoNamedStringArgs>();

            Assert.AreEqual("defaultA", a.a);
            Assert.AreEqual("defaultB", a.b);
            cb.BindNamedParameter <TwoNamedStringArgs.A, string>(GenericType <TwoNamedStringArgs.A> .Class, "not defaultA");
            cb.BindNamedParameter <TwoNamedStringArgs.B, string>(GenericType <TwoNamedStringArgs.B> .Class, "not defaultB");
            IInjector i   = tang.NewInjector(cb.Build());
            string    msg = null;

            try
            {
                i.BindVolatileParameter(GenericType <TwoNamedStringArgs.A> .Class, "not defaultA");
                i.BindVolatileParameter(GenericType <TwoNamedStringArgs.B> .Class, "not defaultB");
                msg =
                    "Attempt to re-bind named parameter TwoNamedStringArgs+A.  Old value was [not defaultA] new value is [not defaultA]";
            }
            catch (Exception)
            {
            }
            Assert.IsNull(msg);
        }