public void GetValuesTest()
        {
            var target = new object();
            var value1 = new object();
            var value2 = new object();

            _provider.GetValues(target, (s, o) => true).ShouldBeEmpty();
            _provider.SetValue(target, FirstPath, value1);
            _provider.SetValue(target, SecondPath, value2);

            var list = _provider.GetValues(target, (s, o) => true);

            list.Any(pair => pair.Key == FirstPath).ShouldBeTrue();
            list.Any(pair => pair.Key == SecondPath).ShouldBeTrue();
            list.Any(pair => pair.Value == value1).ShouldBeTrue();
            list.Any(pair => pair.Value == value2).ShouldBeTrue();

            list = _provider.GetValues(target, (s, o) => s == FirstPath && o == value1);
            list.Single().Key.ShouldEqual(FirstPath);
            list.Single().Value.ShouldEqual(value1);
        }
Ejemplo n.º 2
0
        public virtual void ClearBindings(object target, IDataContext context = null)
        {
            Should.NotBeNull(target, nameof(target));
            IAttachedValueProvider provider = ServiceProvider.AttachedValueProvider;
            var values = provider.GetValues(target, GetBindingPredicateDelegate);

            for (int index = 0; index < values.Count; index++)
            {
                var value = values[index];
                ClearBinding((IDataBinding)value.Value);
                provider.Clear(target, value.Key);
            }
        }