コード例 #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);
        }