Esempio n. 1
0
        public void WhenSourceValueChangedAndItIsAnEnumerableItShouldBePassedToTarget()
        {
            var expectedItems = new List <object> {
                1, 2
            };
            var binding = new SetBinding(_targetAdapter, _sourceAdapter, _comparer);

            _sourceAdapter.ValueChangedCallback(new List <object> {
                1, 1, 2, 2
            });

            CollectionAssert.AreEquivalent(expectedItems, _targetAdapter.Items);
        }
Esempio n. 2
0
        public void WhenSourceValueChangedAndIsNoValueThenTargetValueShouldNotBeChanged()
        {
            var sourceAdapter = new ValueAdapter();
            var targetAdapter = new ValueAdapter();
            var binding       = new ValueBinding(targetAdapter, sourceAdapter);

            sourceAdapter.ValueChangedCallback(SettingsConstants.NoValue);

            Assert.IsFalse(targetAdapter.SetValueCalled);
        }
Esempio n. 3
0
        public void WhenTargetValueChangesItShouldBePassedToSource()
        {
            var sourceAdapter = new ValueAdapter();
            var targetAdapter = new ValueAdapter();
            var binding       = new ValueBinding(targetAdapter, sourceAdapter);

            targetAdapter.ValueChangedCallback(5);

            Assert.AreEqual(5, sourceAdapter.Value);
        }
Esempio n. 4
0
        public void ShouldForwardConvertedValueFromSourceValueChangedCallback()
        {
            var    sourceAdapter = new ValueAdapter();
            var    adapter       = new ExceptionHandlingAdapter(sourceAdapter, IgnoreException);
            object actualValue   = null;

            adapter.ValueChangedCallback = newValue => actualValue = newValue;

            sourceAdapter.ValueChangedCallback(5);

            Assert.AreEqual(5, actualValue);
        }
Esempio n. 5
0
        public void ShouldForwardSourceValueChangedCallbackCalls()
        {
            var sourceAdapter  = new ValueAdapter();
            var adapter        = new ExceptionHandlingAdapter(sourceAdapter, IgnoreException);
            var callbackCalled = false;

            adapter.ValueChangedCallback = newValue => callbackCalled = true;

            sourceAdapter.ValueChangedCallback(5);

            Assert.IsTrue(callbackCalled);
        }
Esempio n. 6
0
        public void ShouldForwardSourceValueChangedCallbackCalls()
        {
            var  converter     = new ValueConverter();
            var  sourceAdapter = new ValueAdapter();
            var  adapter       = new ConvertingAdapter(sourceAdapter, converter);
            bool wasCalled     = false;

            adapter.ValueChangedCallback = _ => { wasCalled = true; };
            sourceAdapter.ValueChangedCallback(null);

            Assert.IsTrue(wasCalled);
        }
Esempio n. 7
0
        public void ShouldForwardConvertedValueFromSourceValueChangedCallback()
        {
            var converter = new ValueConverter {
                ReturnedSource = 5
            };
            var    sourceAdapter = new ValueAdapter();
            var    adapter       = new ConvertingAdapter(sourceAdapter, converter);
            object actualValue   = null;

            adapter.ValueChangedCallback = value => { actualValue = value; };
            sourceAdapter.ValueChangedCallback(1);

            Assert.AreEqual(5, actualValue);
        }