public void TestDefaultChangedWithUpstreamRejection()
        {
            Bindable <string> bindable1 = new Bindable <string>("won't change");
            Bindable <string> bindable2 = bindable1.GetBoundCopy();

            int changed1 = 0, changed2 = 0;

            bindable1.DefaultChanged += v => changed1++;
            bindable2.DefaultChanged += _ =>
            {
                bindable2.Default = "won't change";
                changed2++;
            };

            bindable1.Default = "new value";

            Assert.AreEqual("won't change", bindable1.Default);
            Assert.AreEqual(bindable1.Default, bindable2.Default);

            // bindable1 should only receive the final value changed, skipping the intermediary (overidden) one.
            Assert.AreEqual(1, changed1);
            Assert.AreEqual(2, changed2);
        }
        public void TestDisabledChangedWithUpstreamRejection()
        {
            Bindable <string> bindable1 = new Bindable <string>("won't change");
            Bindable <string> bindable2 = bindable1.GetBoundCopy();

            int changed1 = 0, changed2 = 0;

            bindable1.DisabledChanged += v => changed1++;
            bindable2.DisabledChanged += _ =>
            {
                bindable2.Disabled = false;
                changed2++;
            };

            bindable1.Disabled = true;

            Assert.IsFalse(bindable1.Disabled);
            Assert.IsFalse(bindable2.Disabled);

            // bindable1 should only receive the final disabled changed, skipping the intermediary (overidden) one.
            Assert.AreEqual(1, changed1);
            Assert.AreEqual(2, changed2);
        }
        public void TestDisabledChanged()
        {
            Bindable <string> bindable1 = new Bindable <string>("default");
            Bindable <string> bindable2 = bindable1.GetBoundCopy();
            Bindable <string> bindable3 = bindable2.GetBoundCopy();

            bool disabled1 = false, disabled2 = false, disabled3 = false;

            bindable1.DisabledChanged += v => disabled1 = v;
            bindable2.DisabledChanged += v => disabled2 = v;
            bindable3.DisabledChanged += v => disabled3 = v;

            bindable1.Disabled = true;

            Assert.AreEqual(true, disabled1);
            Assert.AreEqual(true, disabled2);
            Assert.AreEqual(true, disabled3);

            bindable1.Disabled = false;

            Assert.AreEqual(false, disabled1);
            Assert.AreEqual(false, disabled2);
            Assert.AreEqual(false, disabled3);
        }
示例#4
0
 private void load(Bindable <Drawable> inspected)
 {
     inspectedDrawable = inspected.GetBoundCopy();
 }