Esempio n. 1
0
        public void CheckPropertyClassNullPath()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("", propertyManager);

            PropertyNode stringNode1 = propertyManager.GetPropertyNode("AStringProperty");
            PropertyNode intNode1    = propertyManager.GetPropertyNode("AnIntProperty");
            PropertyNode doubleNode1 = propertyManager.GetPropertyNode("ADoubleProperty");
            PropertyNode floatNode1  = propertyManager.GetPropertyNode("AFloatProperty");
            PropertyNode boolNode1   = propertyManager.GetPropertyNode("ABoolProperty");

            stringNode1.Set("Hello World!");
            intNode1.Set(10);
            doubleNode1.Set(10.123);
            floatNode1.Set(10.321f);
            boolNode1.Set(true);

            Assert.AreEqual("Hello World!", stringNode1.Get());
            Assert.AreEqual(10, intNode1.Get());
            Assert.AreEqual(10.123, doubleNode1.Get());
            Assert.AreEqual(10.321f, floatNode1.Get());
            Assert.AreEqual(true, boolNode1.Get());
        }
Esempio n. 2
0
        public void CheckPropertyFloat()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode floatNode1 = propertyManager.GetPropertyNode("c1/AFloatProperty");

            floatNode1.Set(20.123f);
            Assert.AreEqual(20.123f, floatNode1.Get());
        }
Esempio n. 3
0
        public void CheckPropertyDouble()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode doubleNode1 = propertyManager.GetPropertyNode("c1/ADoubleProperty");

            doubleNode1.Set(20.123);
            Assert.AreEqual(20.123, doubleNode1.Get());
        }
Esempio n. 4
0
        public void CheckPropertyInt()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode intNode1 = propertyManager.GetPropertyNode("c1/AnIntProperty");

            intNode1.Set(10);
            Assert.AreEqual(10, intNode1.Get());
        }
Esempio n. 5
0
        public void CheckPropertyString()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode stringNode1 = propertyManager.GetPropertyNode("c1/AStringProperty");

            stringNode1.Set("Hello World!");
            Assert.AreEqual("Hello World!", stringNode1.Get());
        }
Esempio n. 6
0
        public void CheckPropertyIntDelegate()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode intNode1 = propertyManager.GetPropertyNode("c1/AnIntProperty");

            intNode1.Set(10);

            PropertyNode.GetInt32ValueDelegate prop = intNode1.GetInt32Delegate;
            Assert.AreEqual(10, prop());
        }
Esempio n. 7
0
        public void CheckPropertyDoubleDelegate()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode doubleNode1 = propertyManager.GetPropertyNode("c1/ADoubleProperty");

            doubleNode1.Set(10.123456);

            PropertyNode.GetDoubleValueDelegate prop = doubleNode1.GetDoubleDelegate;

            Assert.AreEqual(10.123456, prop());
        }
Esempio n. 8
0
        public void CheckPropertyClass1()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();
            ClassWithProperties class2 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);
            class2.Bind("c2", propertyManager);

            PropertyNode stringNode1 = propertyManager.GetPropertyNode("c1/AStringProperty");
            PropertyNode intNode1    = propertyManager.GetPropertyNode("c1/AnIntProperty");
            PropertyNode doubleNode1 = propertyManager.GetPropertyNode("c1/ADoubleProperty");
            PropertyNode floatNode1  = propertyManager.GetPropertyNode("c1/AFloatProperty");
            PropertyNode boolNode1   = propertyManager.GetPropertyNode("c1/ABoolProperty");

            stringNode1.Set("Hello World!");
            intNode1.Set(10);
            doubleNode1.Set(10.123);
            floatNode1.Set(10.321f);
            boolNode1.Set(true);

            PropertyNode stringNode2 = propertyManager.GetPropertyNode("c2/AStringProperty");
            PropertyNode intNode2    = propertyManager.GetPropertyNode("c2/AnIntProperty");
            PropertyNode doubleNode2 = propertyManager.GetPropertyNode("c2/ADoubleProperty");
            PropertyNode floatNode2  = propertyManager.GetPropertyNode("c2/AFloatProperty");
            PropertyNode boolNode2   = propertyManager.GetPropertyNode("c2/ABoolProperty");

            stringNode2.Set("Goodbye World!");
            intNode2.Set(20);
            doubleNode2.Set(20.123);
            floatNode2.Set(20.321f);
            boolNode2.Set(true);

            Assert.AreEqual("Hello World!", stringNode1.Get());
            Assert.AreEqual(10, intNode1.Get());
            Assert.AreEqual(10.123, doubleNode1.Get());
            Assert.AreEqual(10.321f, floatNode1.Get());
            Assert.AreEqual(true, boolNode1.Get());

            Assert.AreEqual("Goodbye World!", stringNode2.Get());
            Assert.AreEqual(20, intNode2.Get());
            Assert.AreEqual(20.123, doubleNode2.Get());
            Assert.AreEqual(20.321f, floatNode2.Get());
            Assert.AreEqual(true, boolNode2.Get());
        }
Esempio n. 9
0
        public void CheckPropertyName01()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("c1", propertyManager);

            PropertyNode intNode1 = propertyManager.GetPropertyNode("/c1/AnIntProperty");

            Assert.AreEqual("AnIntProperty", intNode1.GetName());
            Assert.AreEqual("AnIntProperty", intNode1.GetPrintableName());
            Assert.AreEqual("/c1/AnIntProperty", intNode1.GetFullyQualifiedName());
            Assert.AreEqual("AnIntProperty", intNode1.GetDisplayName(true));
            Assert.AreEqual("AnIntProperty[0]", intNode1.GetDisplayName(false));
            Assert.AreEqual("/c1/AnIntProperty", intNode1.GetPath(true));
            Assert.AreEqual("/c1[0]/AnIntProperty[0]", intNode1.GetPath(false));
        }
Esempio n. 10
0
        public void CheckPropertyClassPerformance()
        {
            PropertyManager propertyManager = new PropertyManager();

            ClassWithProperties class1 = new ClassWithProperties();

            class1.Bind("", propertyManager);

            PropertyNode doubleNode1 = propertyManager.GetPropertyNode("ADoubleProperty");

            doubleNode1.Set(10.123);

            double   val;
            DateTime time = DateTime.Now;

            for (int i = 0; i <= maxCnt; i++)
            {
                val = class1.PropertyInt;
            }
            long mlsg = DateTime.Now.Ticks - time.Ticks;

            Console.WriteLine("Time for Performance test (using property directly) =" + (double)mlsg / 10000000.0f);

            time = DateTime.Now;
            for (int i = 0; i <= maxCnt; i++)
            {
                val = doubleNode1.GetDouble();
            }
            mlsg = DateTime.Now.Ticks - time.Ticks;
            Console.WriteLine("Time for Performance test (using PropertyNode) =" + (double)mlsg / 10000000.0f);

            PropertyNode.GetDoubleValueDelegate prop = doubleNode1.GetDoubleDelegate;

            time = DateTime.Now;
            for (int i = 0; i <= maxCnt; i++)
            {
                val = prop();
            }
            mlsg = DateTime.Now.Ticks - time.Ticks;
            Console.WriteLine("Time for Performance test (using PropertyNode's delegate) =" + (double)mlsg / 10000000.0f);
        }