public void BindingTargetShouldUseDelegateIsEnabledProperty() { bool isEnabled = false; IAttachedBindingMemberInfo <object, bool> member = AttachedBindingMember.CreateMember <object, bool>(AttachedMemberConstants.Enabled, (info, o) => isEnabled, (info, o, v) => isEnabled = v); var memberProvider = new BindingMemberProvider(); memberProvider.Register(typeof(object), member, false); BindingServiceProvider.MemberProvider = memberProvider; var mock = new ObserverMock { PathMembers = new BindingPathMembersMock(new object(), BindingPath.Empty) }; var bindingTarget = (BindingTarget)CreateBindingSource(mock); bindingTarget.IsEnabled.ShouldBeFalse(); bindingTarget.IsEnabled = true; isEnabled.ShouldBeTrue(); bindingTarget.IsEnabled.ShouldBeTrue(); bindingTarget.IsEnabled = false; isEnabled.ShouldBeFalse(); bindingTarget.IsEnabled.ShouldBeFalse(); }
public void AccessorShouldToggleEnabledFalse() { bool canExecute = false; bool isInvoked = false; var parameter = new object(); var command = new RelayCommand(o => { }, o => { o.ShouldEqual(parameter); isInvoked = true; return(canExecute); }, this); bool isEnabled = true; IAttachedBindingMemberInfo <object, bool> member = AttachedBindingMember.CreateMember <object, bool>(AttachedMemberConstants.Enabled, (info, o) => isEnabled, (info, o, v) => isEnabled = v); var memberProvider = new BindingMemberProvider(); memberProvider.Register(typeof(object), member, false); BindingServiceProvider.MemberProvider = memberProvider; var srcAccessor = new BindingSourceAccessorMock(); var source = new BindingSourceModel(); var accessor = GetAccessor(source, BindingSourceModel.EventName, new DataContext(BindingBuilderConstants.ToggleEnabledState.ToValue(false)), false, d => parameter); srcAccessor.GetValue = (info, context, arg3) => command; isEnabled.ShouldBeTrue(); accessor.SetValue(srcAccessor, EmptyContext, true); isInvoked.ShouldBeFalse(); isEnabled.ShouldBeTrue(); isInvoked = false; canExecute = true; command.RaiseCanExecuteChanged(); isInvoked.ShouldBeFalse(); isEnabled.ShouldBeTrue(); }
public void BindingTargetShouldUseDelegateIsEnabledProperty() { bool isEnabled = false; IAttachedBindingMemberInfo<object, bool> member = AttachedBindingMember.CreateMember<object, bool>(AttachedMemberConstants.Enabled, (info, o) => isEnabled, (info, o, v) => isEnabled = v); var memberProvider = new BindingMemberProvider(); memberProvider.Register(typeof(object), member, false); BindingServiceProvider.MemberProvider = memberProvider; var mock = new ObserverMock { PathMembers = new BindingPathMembersMock(new object(), BindingPath.Empty) }; var bindingTarget = (BindingTarget)CreateBindingSource(mock); bindingTarget.IsEnabled.ShouldBeFalse(); bindingTarget.IsEnabled = true; isEnabled.ShouldBeTrue(); bindingTarget.IsEnabled.ShouldBeTrue(); bindingTarget.IsEnabled = false; isEnabled.ShouldBeFalse(); bindingTarget.IsEnabled.ShouldBeFalse(); }
public void AccessorShouldToggleEnabledFalse() { bool canExecute = false; bool isInvoked = false; var parameter = new object(); var command = new RelayCommand(o => { }, o => { o.ShouldEqual(parameter); isInvoked = true; return canExecute; }, this); bool isEnabled = true; IAttachedBindingMemberInfo<object, bool> member = AttachedBindingMember.CreateMember<object, bool>(AttachedMemberConstants.Enabled, (info, o) => isEnabled, (info, o, v) => isEnabled = v); var memberProvider = new BindingMemberProvider(); memberProvider.Register(typeof(object), member, false); BindingServiceProvider.MemberProvider = memberProvider; var srcAccessor = new BindingSourceAccessorMock(); var source = new BindingSourceModel(); var accessor = GetAccessor(source, BindingSourceModel.EventName, new DataContext(BindingBuilderConstants.ToggleEnabledState.ToValue(false)), false, d => parameter); srcAccessor.GetValue = (info, context, arg3) => command; isEnabled.ShouldBeTrue(); accessor.SetValue(srcAccessor, EmptyContext, true); isInvoked.ShouldBeFalse(); isEnabled.ShouldBeTrue(); isInvoked = false; canExecute = true; command.RaiseCanExecuteChanged(); isInvoked.ShouldBeFalse(); isEnabled.ShouldBeTrue(); }
public BindingMemberProviderEx([NotNull] BindingMemberProvider provider) : base(provider) { }