Ejemplo n.º 1
0
        public void Traverse_Property_SetValue()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);
            var trv      = Traverse.Create(instance);

            for (var i = 0; i < TraverseProperties.testStrings.Length - 1; i++)
            {
                var newValue = "newvalue" + i;

                // before
                Assert.AreEqual(TraverseProperties.testStrings[i], instance.GetTestProperty(i));

                var name = TraverseProperties.propertyNames[i];
                var ptrv = trv.Property(name);
                Assert.IsNotNull(ptrv);
                ptrv.SetValue(newValue);

                // after
                if (name == "BaseProperty2")
                {
                    // BaseProperty2 is only defined in base class
                    Assert.AreEqual(TraverseProperties.testStrings[i], instance.GetTestProperty(i));
                    Assert.IsNull(ptrv.GetValue());
                    Assert.IsNull(ptrv.GetValue <string>());
                }
                else
                {
                    Assert.AreEqual(newValue, instance.GetTestProperty(i));
                    Assert.AreEqual(newValue, ptrv.GetValue());
                    Assert.AreEqual(newValue, ptrv.GetValue <string>());
                }
            }
        }
        public void Traverse_Property_ToString()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);

            var trv = Traverse.Create(instance).Property(TraverseProperties.propertyNames[0]);

            Assert.AreEqual(TraverseProperties.testStrings[0], trv.ToString());
        }
        public void Traverse_Property_ToString()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);

            for (var i = 0; i < TraverseProperties.testStrings.Length; i++)
            {
                var trv = Traverse.Create(instance).Property(TraverseProperties.propertyNames[i]);
                Assert.AreEqual(TraverseProperties.testStrings[i], trv.ToString());
            }
        }
Ejemplo n.º 4
0
        public void Traverse_Property_GetValue()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);
            var trv      = Traverse.Create(instance);

            for (var i = 0; i < TraverseProperties.testStrings.Length; i++)
            {
                var name = TraverseProperties.propertyNames[i];
                var ptrv = trv.Property(name);
                Assert.NotNull(ptrv);
                Assert.AreEqual(TraverseProperties.testStrings[i], ptrv.GetValue());
                Assert.AreEqual(TraverseProperties.testStrings[i], ptrv.GetValue <string>());
            }
        }
        public void Traverse_Property_SetValue()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);
            var trv      = Traverse.Create(instance);

            for (var i = 0; i < TraverseProperties.testStrings.Length - 1; i++)
            {
                var newValue = "newvalue" + i;

                // before
                Assert.AreEqual(TraverseProperties.testStrings[i], instance.GetTestProperty(i));

                var name = TraverseProperties.propertyNames[i];
                var ptrv = trv.Property(name);
                ptrv.SetValue(newValue);

                // after
                Assert.AreEqual(newValue, instance.GetTestProperty(i));
                Assert.AreEqual(newValue, ptrv.GetValue());
                Assert.AreEqual(newValue, ptrv.GetValue <string>());
            }
        }
Ejemplo n.º 6
0
        public void Traverse_Property_GetValue()
        {
            var instance = new TraverseProperties_AccessModifiers(TraverseProperties.testStrings);
            var trv      = Traverse.Create(instance);

            for (var i = 0; i < TraverseProperties.testStrings.Length; i++)
            {
                var name = TraverseProperties.propertyNames[i];
                var ptrv = trv.Property(name);
                Assert.IsNotNull(ptrv);
                if (name == "BaseProperty2")
                {
                    // BaseProperty2 is only defined in base class
                    Assert.IsNull(ptrv.GetValue());
                    Assert.IsNull(ptrv.GetValue <string>());
                }
                else
                {
                    Assert.AreEqual(TraverseProperties.testStrings[i], ptrv.GetValue());
                    Assert.AreEqual(TraverseProperties.testStrings[i], ptrv.GetValue <string>());
                }
            }
        }