コード例 #1
0
        public void GetSetTest()
        {
            var bindable = new Bindable <int>();

            bindable.Set(10);

            // ge the value using Get();
            var val = bindable.Get();

            Assert.AreEqual(10, val, "The value should be set correctly");

            // get the value using implicit assignment operator
            int val2 = bindable;

            Assert.AreEqual(10, val2, "The returned value should be 10");
        }
コード例 #2
0
        public void ForwardOnChangeTest()
        {
            // setup
            var events = new BindableEvents(new Bindable <int>());
            var bindableToForwardFrom = new Bindable <string>();

            bindableToForwardFrom.Set("test");
            // register forward
            events.ForwardOnChange(bindableToForwardFrom);

            var counter = 0;

            events.Add((c, o) => { counter++; });
            // dispatch
            bindableToForwardFrom.Dispatch();

            Assert.AreEqual(1, counter, "The event should be forwarded once.");

            // remove the listener and dispatch again
            events.RemoveForwardedOnChange(bindableToForwardFrom);
            bindableToForwardFrom.Dispatch();

            Assert.AreEqual(1, counter, "The event should not be forwarded again.");
        }