public void TestMaxValueChangedWithUpstreamRejection()
        {
            BindableInt bindable1 = new BindableInt(1337); // Won't change
            BindableInt bindable2 = new BindableInt();

            bindable2.BindTo(bindable1);

            int changed1 = 0, changed2 = 0;

            bindable1.MaxValueChanged += v => changed1++;
            bindable2.MaxValueChanged += _ =>
            {
                bindable2.MaxValue = 1337;
                changed2++;
            };

            bindable1.MaxValue = 2;

            Assert.AreEqual(1337, bindable1.MaxValue);
            Assert.AreEqual(bindable1.MaxValue, bindable2.MaxValue);

            // bindable1 should only receive the final value changed, skipping the intermediary (overidden) one.
            Assert.AreEqual(1, changed1);
            Assert.AreEqual(2, changed2);
        }
Пример #2
0
        private void load(MatchIPCInfo ipc)
        {
            score1.BindValueChanged(_ => updateScores());
            score1.BindTo(ipc.Score1);

            score2.BindValueChanged(_ => updateScores());
            score2.BindTo(ipc.Score2);
        }
 private void load([CanBeNull] TestBrowser browser)
 {
     if (browser != null)
     {
         recordState.BindTo(browser.RecordState);
         currentFrame.BindTo(browser.CurrentFrame);
     }
 }
        public void TestMaxValueChanged()
        {
            BindableInt bindable1 = new BindableInt();
            BindableInt bindable2 = new BindableInt();

            bindable2.BindTo(bindable1);

            int minValue1 = 0, minValue2 = 0;

            bindable1.MaxValueChanged += v => minValue1 = v;
            bindable2.MaxValueChanged += v => minValue2 = v;

            bindable1.MaxValue = 1;

            Assert.AreEqual(1, minValue1);
            Assert.AreEqual(1, minValue2);

            bindable1.MaxValue = 2;

            Assert.AreEqual(2, minValue1);
            Assert.AreEqual(2, minValue2);
        }