示例#1
0
        public void ChangePropertyAction()
        {
            var c    = new TestChangePropertyAction();
            var item = new ActionItem();

            c.TargetObject = item;
            c.PropertyPath = "MyString";
            c.Value        = "My value";
            c.TestInvoke();

            Assert.AreEqual("My value", item.MyString);
        }
示例#2
0
        public void ChangePropertyAction_Converts_Value()
        {
            var c    = new TestChangePropertyAction();
            var item = new GenericActionItem <Brush> {
            };

            c.TargetObject = item;
            c.PropertyPath = "MyProperty";
            c.Value        = "Red";
            c.TestInvoke();

            Assert.AreEqual(new SolidColorBrush(Colors.Red).ToString(), item.MyProperty.ToString());
        }
示例#3
0
        public void ChangePropertyAction_Converts_Int()
        {
            var c    = new TestChangePropertyAction();
            var item = new GenericActionItem <int> {
            };

            c.TargetObject = item;
            c.PropertyPath = "MyProperty";
            c.Value        = "10";
            c.TestInvoke();

            Assert.AreEqual(10, item.MyProperty);
        }
示例#4
0
        public void ChangePropertyAction_Not_Set_Sub_Item_If_Null()
        {
            var c    = new TestChangePropertyAction();
            var item = new ActionItem {
            };

            c.TargetObject = item;
            c.PropertyPath = "MyInner.MyInnerString";
            c.Value        = "My value";
            c.TestInvoke();

            Assert.AreEqual(null, item.MyInner);
        }
示例#5
0
        public void ChangePropertyAction_With_Sub_Item()
        {
            var c    = new TestChangePropertyAction();
            var item = new ActionItem {
                MyInner = new SubFilteredItem {
                }
            };

            c.TargetObject = item;
            c.PropertyPath = "MyInner.MyInnerString";
            c.Value        = "My value";
            c.TestInvoke();

            Assert.AreEqual("My value", item.MyInner.MyInnerString);
        }
示例#6
0
        public void ChangePropertyAction_With_Culture()
        {
            var c    = new TestChangePropertyAction();
            var item = new GenericActionItem <DateTime>();

            var date           = new DateTime(2019, 07, 18);
            var dateAsStringFr = date.ToString(CultureInfo.GetCultureInfo("fr")); // 18/07/2019 00:00:00

            c.TargetObject = item;
            c.PropertyPath = "MyProperty";
            c.Value        = dateAsStringFr;
            c.Culture      = CultureInfo.GetCultureInfo("fr");
            c.TestInvoke();

            Assert.AreEqual(date, item.MyProperty);
        }