Esempio n. 1
0
        public void CapturesObjectAsBean()
        {
            int    a = 330;
            float  b = 12.784f;
            string c = "paradigm";

            TestClass captive = new TestClass(a, b, c);

            Bean bean = new Bean(captive);

            Assert.IsTrue(bean.HasValue("A"));
            Assert.IsTrue(bean.HasValue("B"));
            Assert.IsTrue(bean.HasValue("C"));
            Assert.AreEqual(a.ToString(), bean.GetValue("A"));
            Assert.AreEqual(b.ToString(), bean.GetValue("B"));
            Assert.AreEqual(c, bean.GetValue("C"));
        }
Esempio n. 2
0
        public void CapturesMultipleObjectsAsBean()
        {
            int    a = 330;
            float  b = 12.784f;
            string c = "paradigm";

            TestClass captive = new TestClass(a, b, c);

            string c2 = "porcupine";
            int    d  = 990;
            object e  = new OperatingSystem(PlatformID.Unix, new Version());

            AnotherTestClass captive2 = new AnotherTestClass(c2, d, e);

            Bean bean = new Bean(captive);

            bool overwrite = false;

            bean.Capture(captive2, overwrite);

            Assert.IsTrue(bean.HasValue("A"));
            Assert.IsTrue(bean.HasValue("B"));
            Assert.IsTrue(bean.HasValue("C"));
            Assert.IsTrue(bean.HasValue("D"));
            Assert.IsTrue(bean.HasValue("E"));
            Assert.AreEqual(a.ToString(), bean.GetValue("A"));
            Assert.AreEqual(b.ToString(), bean.GetValue("B"));
            Assert.AreEqual(c, bean.GetValue("C"));
            Assert.AreEqual(d.ToString(), bean.GetValue("D"));
            Assert.AreEqual(e.ToString(), bean.GetValue("E"));

            overwrite = true;

            bean.Capture(captive2, overwrite);

            Assert.IsTrue(bean.HasValue("A"));
            Assert.IsTrue(bean.HasValue("B"));
            Assert.IsTrue(bean.HasValue("C"));
            Assert.IsTrue(bean.HasValue("D"));
            Assert.IsTrue(bean.HasValue("E"));
            Assert.AreEqual(a.ToString(), bean.GetValue("A"));
            Assert.AreEqual(b.ToString(), bean.GetValue("B"));
            Assert.AreEqual(c2, bean.GetValue("C"));
            Assert.AreEqual(d.ToString(), bean.GetValue("D"));
            Assert.AreEqual(e.ToString(), bean.GetValue("E"));
        }
Esempio n. 3
0
        public void BeanIsIndexable()
        {
            int    a = 330;
            float  b = 12.784f;
            string c = "paradigm";

            TestClass captive = new TestClass(a, b, c);

            Bean bean = new Bean(captive);

            Assert.AreEqual(bean.GetValue("A"), bean["A"]);
            Assert.AreEqual("330", bean["A"]);

            Assert.AreEqual(bean.GetValue("B"), bean["B"]);
            Assert.AreEqual("12.784", bean["B"]);

            Assert.AreEqual(bean.GetValue("C"), bean["C"]);
            Assert.AreEqual("paradigm", bean["C"]);
        }