Example #1
0
        public void TwoWayBinding_UpdateSource_ValueChanged()
        {
            var source = new Observable <int>();
            var target = new Observable <int>();

            var binding = target.Bind(source).Property(s => s.Value, t => t.Value, Transmute.Transmuter.Default.GetConverter <int, int>());

            source.Value = 5;
            Assert.AreEqual(source.Value, target.Value);

            target.Value = 8;
            Assert.AreEqual(source.Value, target.Value);
        }
Example #2
0
        public void TwoWayBinding_UpdateSource_ValueChanged()
        {
            var source = new Observable <int>();
            var target = new Observable <int>();

            var binding = target.Bind(source).Property(s => s.Value, t => t.Value, Converters.Identity <int>());

            source.Value = 5;
            Assert.AreEqual(source.Value, target.Value);

            target.Value = 8;
            Assert.AreEqual(source.Value, target.Value);
        }
Example #3
0
        public void TwoWayBinding_ReferencesDestroyed_BindingNotAlive()
        {
            IBinding binding = null;

            WeakHelpers.ExecuteAndCollect(() =>
            {
                var source = new Observable <int>();
                var target = new Observable <int>();

                binding = target.Bind(source).Property(s => s.Value, t => t.Value, Transmute.Transmuter.Default.GetConverter <int, int>());
            });

            Assert.IsFalse(binding.IsAlive);
        }
Example #4
0
        public void TwoWayBinding_Unsubscribed_BindingNotAlive()
        {
            IBinding binding = null;

            var source = new Observable <int>();
            var target = new Observable <int>();

            binding = target.Bind(source).Property(s => s.Value, t => t.Value, Transmute.Transmuter.Default.GetConverter <int, int>());

            Assert.IsTrue(binding.IsAlive);

            binding.Dispose();

            Assert.IsFalse(binding.IsAlive);
        }