public void BuilderShouldUseTargetBindingContextForSource4()
        {
            const string sourcePath = "IntProperty";
            var targetObj = new BindingSourceEventNotifierModel();
            var builder = new BindingBuilder();
            builder.Bind(targetObj, () => model => model.ObjectProperty).To<BindingSourceModel>(() => model => model.IntProperty);

            IList<Func<IDataContext, IBindingSource>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(builder);
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
            var sourceObj = new BindingSourceModel();
            BindingServiceProvider.ContextManager.GetBindingContext(targetObj).Value = sourceObj;
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
        }
Exemplo n.º 2
0
        public void ObserverShouldRaiseValueChangedEventWhenPropertyChangedUsingEvent()
        {
            bool isInvoked = false;
            var model = new BindingSourceEventNotifierModel();
            var propertyName = GetMemberPath<BindingSourceEventNotifierModel>(sourceModel => sourceModel.ObjectProperty);
            var observer = CreateObserver(model, propertyName, false);
            observer.ValueChanged += (sender, args) => isInvoked = true;

            isInvoked = false;
            model.ObjectProperty = "test";
            model.RaiseObjectPropertyChanged();
            isInvoked.ShouldBeTrue();
            isInvoked = false;

            model.ObjectProperty = "test1";
            isInvoked.ShouldBeFalse();
        }
        public void BuilderShouldUseSourceObject4()
        {
            const string sourcePath = "IntProperty";
            var targetObj = new BindingSourceEventNotifierModel();
            var sourceObj = new BindingSourceModel();
            var builder = new BindingBuilder();
            builder.Bind(targetObj, () => model => model.ObjectProperty).To(sourceObj, () => model => model.IntProperty);

            IList<Func<IDataContext, IBindingSource>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(builder);
            BindingParserTest.BindingSourceShouldBeValid(source, sourcePath, sourceObj);
        }
Exemplo n.º 4
0
        public void ObserverShouldNotRaiseValueChangedEventWhenPropertyChangedComplexPropertyUsingEventObservableFalse()
        {
            bool isInvoked = false;
            var model = new BindingSourceEventNotifierModel();
            var propertyName = GetMemberPath(model, sourceModel => sourceModel.NestedModel.ObjectProperty);

            var observer = CreateObserver(model, propertyName, false, observable: false);
            observer.ValueChanged += (sender, args) => isInvoked = true;

            isInvoked = false;
            model.NestedModel = new BindingSourceEventNotifierModel();
            model.RaiseNestedModelChanged();
            isInvoked.ShouldBeFalse();

            isInvoked = false;
            model.NestedModel.ObjectProperty = "test";
            model.NestedModel.RaiseObjectPropertyChanged();
            isInvoked.ShouldBeFalse();
            isInvoked = false;

            model.NestedModel.ObjectProperty = 10;
            isInvoked.ShouldBeFalse();
        }