Exemplo n.º 1
0
        public void TestOneNamedStringArgVolatile()
        {
            OneNamedStringArg a = tang.NewInjector().GetInstance <OneNamedStringArg>();

            Assert.AreEqual("default", a.s);
            IInjector i = tang.NewInjector();

            i.BindVolatileParameter(GenericType <OneNamedStringArg.A> .Class, "volatile");
            Assert.AreEqual("volatile", i.GetInstance <OneNamedStringArg>().s);
        }
Exemplo n.º 2
0
        public void TestOneNamedStringArgBind()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
            OneNamedStringArg       a  = tang.NewInjector(cb.Build()).GetInstance <OneNamedStringArg>();

            Assert.AreEqual("default", a.s);
            cb.BindNamedParameter <OneNamedStringArg.A, string>(GenericType <OneNamedStringArg.A> .Class, "not default");
            IInjector i = tang.NewInjector(cb.Build());

            Assert.AreEqual("not default", i.GetInstance <OneNamedStringArg>().s);
        }
Exemplo n.º 3
0
        public void TestOneNamedStringArgCantRebind()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();
            OneNamedStringArg       a  =
                (OneNamedStringArg)tang.NewInjector(cb.Build()).GetInstance(typeof(OneNamedStringArg));

            Assert.AreEqual("default", a.s);
            cb.BindNamedParameter <OneNamedStringArg.A, string>(GenericType <OneNamedStringArg.A> .Class, "not default");
            IInjector i = tang.NewInjector(cb.Build());

            Assert.AreEqual("not default", ((OneNamedStringArg)i.GetInstance(typeof(OneNamedStringArg))).s);
            string msg = null;

            try
            {
                i.BindVolatileParameter(GenericType <OneNamedStringArg.A> .Class, "volatile");
                msg =
                    "Attempt to re-bind named parameter Org.Apache.REEF.Tang.OneNamedStringArg$A.  Old value was [not default] new value is [volatile]";
            }
            catch (Exception)
            {
            }
            Assert.IsNull(msg);
        }