Example #1
0
        static IEnumerable <System.Windows.DependencyObject> FluentRibbonChildResolver(Fluent.Ribbon ribbon)
        {
            /*
             * foreach (var ti in ribbon.Tabs)
             * {
             *  foreach (var group in ti.Groups)
             *  {
             *      foreach (var obj in BindingScope.GetNamedElements(group))
             *          yield return obj;
             *  }
             * }
             */

            var backstage     = ribbon.Menu as Fluent.Backstage;
            var backstageTabs = backstage.Content as Fluent.BackstageTabControl;

            BindingScope.GetNamedElements(backstageTabs);

            foreach (var backstageTab in backstageTabs.Items)
            {
                ///foreach (var obj in BindingScope.GetNamedElements(backstageTab))
                if (backstageTab is ContentControl)
                {
                    foreach (var obj in BindingScope.GetNamedElements((ContentControl)backstageTab))
                    {
                        yield return(obj);
                    }
                }
            }
        }
Example #2
0
        public void TestTwoWayBindingWithPropertyChangeNotification()
        {
            IBusinessObject businessObject = new BusinessObject();
            businessObject.Name = "Foo";

            CheckBox checkbox = new CheckBox();
            checkbox.CreateControl();
            checkbox.BindingContext = new BindingContext();

            using (BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(businessObject);
                CheckBox bindableTarget = scope.CreateTarget(checkbox);

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(1, checkbox.DataBindings.Count);

                Assert.AreSame(businessObject, checkbox.DataBindings[0].DataSource);

                Assert.AreEqual(businessObject.Name, checkbox.Text);

                checkbox.Text = "Bar";
                checkbox.DataBindings[0].WriteValue();

                Assert.AreEqual(checkbox.Text, businessObject.Name);

                businessObject.Name = "Baz";

                Assert.AreEqual(businessObject.Name, checkbox.Text);
            }
        }
Example #3
0
        public void BindTest1()
        {
            var bindingToSyntax = new Mock<IBindingToSyntax<object>>(MockBehavior.Loose);
            var bindingNamed = new Mock<IBindingWhenInNamedWithOrOnSyntax<object>>(MockBehavior.Loose);
            var bInfo = new Mock<IBindInfo>(MockBehavior.Loose);
            var scopeBinder = new Mock<IScopeBinder>(MockBehavior.Loose);
            var scoped = new Mock<IBindingNamedWithOrOnSyntax<object>>(MockBehavior.Loose);
            var typesFrom = new List<Type>();
            var typeTo = typeof (string);
            var bindingScope = new BindingScope("sdrjklgnlsdjkg");

            bindingToSyntax.Name = "bindingToSyntax";
            bindingNamed.Name = "bindingNamed";
            bInfo.Name = "bInfo";
            scopeBinder.Name = "scopeBinder";
            scoped.Name = "scoped";

            bInfo.SetupGet(x => x.From).Returns(typesFrom).Verifiable();
            bInfo.SetupGet(x => x.To).Returns(typeTo).Verifiable();
            bInfo.SetupGet(x => x.Scope).Returns(bindingScope).Verifiable();
            bInfo.SetupGet(x => x.Name).Returns((string)null).Verifiable();
            bindingNamed.Setup(x => x.GetHashCode()).Returns(100.GetHashCode()).Verifiable();
            bindingNamed.Setup(x => x.ToString()).Returns("100").Verifiable();

            scopeBinder.Setup(x => x.InScope(bindingNamed.Object, bindingScope)).Returns(scoped.Object).Verifiable();
            bindingToSyntax.Setup(x => x.To(typeTo)).Returns(bindingNamed.Object).Verifiable();


            new NinjectBinder(types => bindingToSyntax.Object, scopeBinder.Object).Bind(new[] {bInfo.Object});

        }
 private Expression <Func <object, ExecutionContext, object> > CompileClassInitializer(SmalltalkRuntime runtime, SmalltalkNameScope globalNameScope, SmalltalkClass cls)
 {
     return(this.Compile(runtime,
                         BindingScope.ForClassInitializer(cls, globalNameScope),
                         ReservedScope.ForClassInitializer(),
                         String.Format("{0} initializer", this.Binding.Name.Value)));
 }
        public void A_given_UserControl_is_ScopeRoute()
        {
            var userControl = new UserControl();
            var route       = BindingScope.FindScopeNamingRoute(userControl);

            Assert.Same(userControl, route.Root);
        }
Example #6
0
        public void TestUsingOnlySources()
        {
            IBusinessObject obj = new BusinessObject();
            BindingPairHolder bindingPairHolder = new BindingPairHolder();

            using (BindingScope scope = new BindingScope(bindingPairHolder))
            {
                IBusinessObject source = scope.CreateSource(obj);

                Assert.IsNull(bindingPairHolder.ConsumeBindingPair());

                string name = source.Name;

                BindingPair pair = bindingPairHolder.ConsumeBindingPair();
                Assert.IsNotNull(pair);
                Assert.AreEqual(obj, pair.Object);
                Assert.AreEqual("Name", pair.Member);

                short number = source.ShortValue;

                BindingPair anotherPair = bindingPairHolder.ConsumeBindingPair();
                Assert.IsNotNull(anotherPair);
                Assert.AreEqual(obj, anotherPair.Object);
                Assert.AreEqual("ShortValue", anotherPair.Member);
            }
        }
        internal CompilationContext(ExpressionCompiler compiler, BindingScope globalScope, BindingScope reservedScope, Expression self, Expression executionContext, string superLookupScope)
        {
            if (compiler == null)
            {
                throw new ArgumentNullException("compiler");
            }
            if (globalScope == null)
            {
                throw new ArgumentNullException("globalScope");
            }
            if (reservedScope == null)
            {
                throw new ArgumentNullException("reservedScope");
            }
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            this.Compiler                 = compiler;
            this.GlobalScope              = globalScope;
            this.ReservedScope            = reservedScope;
            this.Self                     = self;
            this.ExecutionContextArgument = executionContext;
            this.SuperLookupScope         = superLookupScope;
            this.LocalScope               = new BindingScope();
            this._ReturnLabel             = null; // Lazy init
        }
Example #8
0
        public static T FindDescendant <T>(this DependencyObject parent, string childName)
            where T : DependencyObject
        {
            var elements = BindingScope.GetNamedElements(parent);

            return(elements.FindName(childName) as T);
        }
Example #9
0
        public void EqualsTest()
        {
            var s1 = new BindingScope("123");
            var s2 = new BindingScope("123");
            var s3 = new BindingScope("321");

            Assert.IsTrue(s1 == s2);
            Assert.IsTrue(s2 == s1);
            Assert.IsFalse(s1 == s3);

            Assert.IsFalse(s1 != s2);
            Assert.IsFalse(s2 != s1);
            Assert.IsTrue(s1 != s3);

            Assert.IsTrue(s1.Equals(s2));
            Assert.IsTrue(s1.Equals((object)s2));

            Assert.IsTrue(s1.Equals(s1));
            Assert.IsTrue(s1.Equals((object)s1));

            Assert.IsFalse(s1.Equals(null));
            Assert.IsFalse(s1.Equals((object)null));
            Assert.IsFalse(s1.Equals((object)s3));
            Assert.IsFalse(s1.Equals("123"));
        }
 protected override Expression <Func <object, ExecutionContext, object> > Compile(SmalltalkRuntime runtime, SmalltalkNameScope globalScope)
 {
     return(this.Compile(runtime,
                         BindingScope.ForProgramInitializer(globalScope),
                         ReservedScope.ForProgramInitializer(),
                         "Global initializer"));
 }
Example #11
0
        protected override InitializerCompiler GetInitializerCompiler(NativeLiteralEncodingStrategy literalEncodingStrategy, NativeDynamicCallStrategy dynamicCallStrategy, NativeDiscreteBindingEncodingStrategy discreteBindingEncodingStrategy)
        {
            BindingScope globalScope   = BindingScope.ForClassInitializer((SmalltalkClass)this.Initializer.Binding.Value, this.Compiler.Parameters.Runtime.GlobalScope);
            BindingScope reservedScope = ReservedScope.ForClassInitializer();

            return(this.GetInitializerCompiler(globalScope, reservedScope, literalEncodingStrategy, dynamicCallStrategy, discreteBindingEncodingStrategy));
        }
 protected LateBoundStepDefinitionBindingWithSource(StepDefinitionType stepDefinitionType, IBindingMethod bindingMethod, BindingScope bindingScope, string sourceExpression, Lazy <Tuple <Regex, string> > regexProvider)
     : base(bindingMethod)
 {
     _regexProvider     = regexProvider;
     StepDefinitionType = stepDefinitionType;
     BindingScope       = bindingScope;
     SourceExpression   = sourceExpression;
 }
Example #13
0
        protected override RootCompilationContext GetCompilationContext(MethodNode parseTree, SmalltalkClass cls, Expression self, Expression executionContext, Expression[] arguments)
        {
            SmalltalkNameScope globalNameScope = this.CompilerOptions.GlobalNameScope ?? this.Runtime.GlobalScope;

            BindingScope globalScope   = BindingScope.ForClassMethod(cls, globalNameScope);
            BindingScope reservedScope = ReservedScope.ForClassMethod();

            return(new RootCompilationContext(this, globalScope, reservedScope, self, executionContext, arguments, cls.Name, parseTree.Selector));
        }
        public void Any_DependencyObject_is_ScopeRoot_if_IsScopeRoot_is_true()
        {
            var dependencyObject = new DependencyObject();

            dependencyObject.SetValue(View.IsScopeRootProperty, true);
            var route = BindingScope.FindScopeNamingRoute(dependencyObject);

            Assert.Same(dependencyObject, route.Root);
        }
Example #15
0
        public void A_given_Pages_Content_is_ScopeRoute_if_it_is_a_dependency_object()
        {
            var page = new Page {
                Content = new Control()
            };
            var route = BindingScope.FindScopeNamingRoute(page);

            Assert.Same(page.Content, route.Root);
        }
Example #16
0
        /// <summary>
        /// Creates a binding on a <see cref="Parameter"/>.
        /// </summary>
        /// <param name="target">The target to which the message is applied.</param>
        /// <param name="parameter">The parameter object.</param>
        /// <param name="elementName">The name of the element to bind to.</param>
        /// <param name="path">The path of the element to bind to.</param>
        /// <param name="bindingMode">The binding mode to use.</param>
        public static void BindParameter(FrameworkElement target, Parameter parameter, string elementName, string path, BindingMode bindingMode)
        {
#if XFORMS
            var element = elementName == "$this" ? target : null;

            if (element == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(path))
            {
                path = ConventionManager.GetElementConvention(element.GetType()).ParameterProperty;
            }

            var binding = new Binding(path)
            {
                Source = element,
                Mode   = bindingMode
            };

            parameter.SetBinding(Parameter.ValueProperty, binding);
#else
            var element = elementName == "$this"
                ? target
                : BindingScope.GetNamedElements(target).FindName(elementName);
            if (element == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(path))
            {
                path = ConventionManager.GetElementConvention(element.GetType()).ParameterProperty;
            }
#if WINDOWS_UWP
            var binding = new Binding
            {
                Path   = new PropertyPath(path),
                Source = element,
                Mode   = bindingMode
            };
#else
            var binding = new Binding(path)
            {
                Source = element,
                Mode   = bindingMode
            };
#endif

#if !WINDOWS_UWP
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
#endif

            BindingOperations.SetBinding(parameter, Parameter.ValueProperty, binding);
#endif
        }
Example #17
0
        public void GetHashCodeTest()
        {
            var s1 = new BindingScope("123");
            var s2 = new BindingScope("123");
            var s3 = new BindingScope("321");

            Assert.AreEqual(s1.GetHashCode(), s2.GetHashCode());
            Assert.AreNotEqual(s1.GetHashCode(), s3.GetHashCode());
            Assert.AreNotEqual(s2.GetHashCode(), s3.GetHashCode());
        }
Example #18
0
        private StepDefinitionBinding CreateStepDefinitionBinding(string regex)
        {
            var bindingType   = new BindingType("StepNameReplacerTests", "UnitTests.StepNameReplacerTests");
            var bindingScope  = new BindingScope(null, null, null);
            var bindingMethod = new BindingMethod(bindingType, "", Enumerable.Empty <IBindingParameter>(), bindingType);

            var binding = new StepDefinitionBinding(StepDefinitionType.Given, regex, bindingMethod, bindingScope);

            return(binding);
        }
Example #19
0
        internal RootCompilationContext(ExpressionCompiler compiler, BindingScope globalScope, BindingScope reservedScope, Expression self, Expression executionContext, IEnumerable <Expression> arguments, string superLookupScope, string codeName)
            : base(compiler, globalScope, reservedScope, self, executionContext, superLookupScope)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException("Arguments");
            }

            this.MethodArguments = arguments.ToList().AsReadOnly();
            this.CodeName        = codeName;
            this._HomeContext    = null; // Lazy init
        }
Example #20
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();
            container.PerRequest <IShell, ShellViewModel>();
            container.Singleton <ProcessListViewModel>();
            container.PerRequest <ProcessDetailsViewModel>();

            BindingScope.AddChildResolver <Fluent.Ribbon>(FluentRibbonChildResolver);
        }
Example #21
0
        public void A_given_name_is_found_regardless_of_case_sensitivity()
        {
            var elements = new List <FrameworkElement> {
                new FrameworkElement {
                    Name = "FOO"
                },
            };

            var found = BindingScope.FindName(elements, "foo");

            Assert.NotNull(found);
        }
Example #22
0
        public void TestUsingTargetOutsideScopeShouldFail()
        {
            CheckBox obj = new CheckBox();

            CheckBox target;

            using (BindingScope scope = new BindingScope())
            {
                target = scope.CreateTarget(obj);
            }

            string name = target.Name;
        }
Example #23
0
        public void TestUsingSourceOutsideScopeShouldFail()
        {
            IBusinessObject obj = new BusinessObject();

            IBusinessObject source;

            using (BindingScope scope = new BindingScope())
            {
                source = scope.CreateSource(obj);
            }

            string name = source.Name;
        }
        protected override Expression <Func <object, ExecutionContext, object> > Compile(SmalltalkRuntime runtime, SmalltalkNameScope globalScope)
        {
            PoolBinding poolBinding = globalScope.GetPoolBinding(this.PoolName);

            if ((poolBinding == null) || (poolBinding.Value == null))
            {
                throw new RuntimeCodeGenerationException(String.Format("Cannot find pool named {0}", this.PoolName)); // May be better exception type
            }
            return(this.Compile(runtime,
                                BindingScope.ForPoolInitializer(poolBinding.Value, globalScope),
                                ReservedScope.ForPoolInitializer(),
                                String.Format("{0} initializerFor: {1}", this.PoolName, this.Binding.Name.Value)));
        }
Example #25
0
        protected override InitializerCompiler GetInitializerCompiler(NativeLiteralEncodingStrategy literalEncodingStrategy, NativeDynamicCallStrategy dynamicCallStrategy, NativeDiscreteBindingEncodingStrategy discreteBindingEncodingStrategy)
        {
            PoolBinding poolBinding = this.Compiler.Parameters.Runtime.GlobalScope.GetPoolBinding(this.Initializer.PoolName);

            if ((poolBinding == null) || (poolBinding.Value == null))
            {
                throw new Exception(String.Format("Cannot find pool named {0}", this.Initializer.PoolName)); // May be better exception type
            }
            BindingScope globalScope   = BindingScope.ForPoolInitializer(poolBinding.Value, this.Compiler.Parameters.Runtime.GlobalScope);
            BindingScope reservedScope = ReservedScope.ForPoolInitializer();

            return(this.GetInitializerCompiler(globalScope, reservedScope, literalEncodingStrategy, dynamicCallStrategy, discreteBindingEncodingStrategy));
        }
Example #26
0
 private static IEnumerable <DependencyObject> FluentRibbonChildResolver(Fluent.Ribbon ribbon)
 {
     foreach (var ti in ribbon.Tabs)
     {
         foreach (var group in ti.Groups)
         {
             foreach (var obj in BindingScope.GetNamedElements(group))
             {
                 yield return(obj);
             }
         }
     }
 }
Example #27
0
        public void BindInfoTest1()
        {
            var types = new [] {typeof(int)};
            var bindingScope = new BindingScope("123");
            var type = typeof(string);

            var bi = new BindInfo(bindingScope, types, type);

            Assert.AreEqual(bindingScope, bi.Scope);
            Assert.AreEqual(types, bi.From);
            Assert.AreEqual(type, bi.To);
            Assert.IsNull(bi.Name);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="runtime">Smalltalk runtime responsible for running the code.</param>
 /// <param name="compilerOptions">Options that control the workings of the compiler.</param>
 /// <param name="globalScope">Binding lookup scope with global identifiers, e.g. globals, class variables, instance variables etc.</param>
 /// <param name="reservedScope">Binding lookup scope with reserved identifiers, e.g. "true", "false", "nil" etc.</param>
 public InitializerCompiler(SmalltalkRuntime runtime, CompilerOptions compilerOptions, BindingScope globalScope, BindingScope reservedScope)
     : base(runtime, compilerOptions)
 {
     if (globalScope == null)
     {
         throw new ArgumentNullException("globalScope");
     }
     if (reservedScope == null)
     {
         throw new ArgumentNullException("reservedScope");
     }
     this.GlobalScope   = globalScope;
     this.ReservedScope = reservedScope;
 }
Example #29
0
        public void BindInfoTest2()
        {
            var types = new[] { typeof(int) };
            var bindingScope = new BindingScope("123");
            var type = typeof(string);
            const string name = "123222";

            var bi = new BindInfo(bindingScope, types, type, name);

            Assert.AreEqual(bindingScope, bi.Scope);
            Assert.AreEqual(types, bi.From);
            Assert.AreEqual(type, bi.To);
            Assert.AreEqual(name, bi.Name);
        }
Example #30
0
        public void A_given_match_is_always_the_first_instance_found()
        {
            var elements = new List <FrameworkElement> {
                new FrameworkElement {
                    Name = "Foo"
                },
                new FrameworkElement {
                    Name = "Foo"
                },
            };

            var found = BindingScope.FindName(elements, "Foo");

            Assert.NotSame(elements.Last(), found);
        }
Example #31
0
        public void A_given_name_is_matched_correctly()
        {
            var elements = new List <FrameworkElement> {
                new FrameworkElement {
                    Name = "Bar"
                },
                new FrameworkElement {
                    Name = "Foo"
                },
            };

            var found = BindingScope.FindName(elements, "Foo");

            Assert.NotNull(found);
        }
Example #32
0
        public void TestOneWayBinding()
        {
            IBusinessObject businessObject = new BusinessObject();
            businessObject.Name = "Foo";

            TextBox textbox = new TextBox();
            textbox.CreateControl();
            textbox.BindingContext = new BindingContext();

            using (BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(businessObject);
                TextBox bindableTarget = scope.CreateTarget(textbox);
            }
        }
Example #33
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            BindingScope.AddChildResolver <Fluent.Ribbon>(FluentRibbonChildResolver);

            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <ISolutionManager, SolutionManager>();
            container.Singleton <ILogger, SimpleLogger>();
            container.PerRequest <ShellViewModel>();

            var configuration = GetConfiguration();
            var appSettings   = new AppSettings();

            configuration.GetSection("AppSettings").Bind(appSettings);
            container.RegisterInstance(typeof(AppSettings), "", appSettings);
        }
Example #34
0
        /// <summary>
        /// Consumes builder to fill out attributes.
        /// </summary>
        /// <param name="component">The component to pull method information from.</param>
        private CachedMethod(ICachedMethodComponent component) : base(component)
        {
            Name       = component._Name;
            ReturnType = component._ReturnType;
            Parameters = component._Parameters;
            methodBase = component._MethodBase;

            // find attribute information
            Provides    = HasAttribute(typeof(ProvidesAttribute));
            Scope       = GetAttribute <ScopeAttribute>()?.Scope ?? BindingScope.Instance;
            BindingName = GetAttribute <NamedAttribute>()?.Name;
            if (BindingName == null)
            {
                List <Attribute> bindingAttributes = GetAttributeWithParent <BindingAttribute>();
                if (bindingAttributes.Count == 1)
                {
                    BindingName = bindingAttributes[0].GetType().FullName;
                }
            }
        }
Example #35
0
        public void Bind(Type service, Type implementation, BindingScope scope)
        {
            Lifestyle lifeStyle;

            switch (scope)
            {
            case BindingScope.Transient:
                lifeStyle = Lifestyle.Transient;
                break;

            case BindingScope.Singleton:
                lifeStyle = Lifestyle.Singleton;
                break;

            default:
                throw new ArgumentException(
                          nameof(scope),
                          $"Binding scope {scope} is not handled");
            }

            this.Container.Register(service, implementation, lifeStyle);
        }
Example #36
0
 public IBindingNamedWithOrOnSyntax<object> InScope(IBindingWhenInNamedWithOrOnSyntax<object> binded, BindingScope scope)
 {
     if (binded == null) throw new ArgumentNullException(nameof(binded));
     if (scope == null) throw new ArgumentNullException(nameof(scope));
     IBindingNamedWithOrOnSyntax<object> scoped;
     if (scope == BindingScope.SingletonScope)
     {
         scoped = binded.InSingletonScope();
     }
     else if (scope == BindingScope.ThreadScope)
     {
         scoped = binded.InThreadScope();
     }
     else if (scope == BindingScope.TransientScope)
     {
         scoped = binded.InTransientScope();
     }
     else
     {
         throw new NotSupportedException($"Undefined scope {scope}");
     }
     return scoped;
 }
        private void ProcessHookAttribute(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes, BindingSourceAttribute hookAttribute)
        {
            var scopes = methodScopes.AsEnumerable();

			// HACK: Currently on mono to compile we have to pass the optional parameter to TryGetParamsAttributeValue
            string[] tags = hookAttribute.TryGetParamsAttributeValue<string>(0, null);
            if (tags != null)
                scopes = scopes.Concat(tags.Select(t => new BindingScope(t, null, null)));

            ApplyForScope(scopes.ToArray(), scope => ProcessHookAttribute(bindingSourceMethod, hookAttribute, scope));
        }
        public void TestBindingToPrintPreviewDialog()
        {
            PrintPreviewDialog control = new PrintPreviewDialog();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                PrintPreviewDialog bindableTarget = scope.CreateTarget(control);

            }
        }
Example #39
0
        private void ProcessStepDefinitionAttribute(BindingSourceMethod bindingSourceMethod, BindingSourceAttribute stepDefinitionAttribute, BindingScope scope)
        {
            var    stepDefinitionTypes = GetStepDefinitionTypes(stepDefinitionAttribute);
            string regex = stepDefinitionAttribute.TryGetAttributeValue <string>(0);

            if (!ValidateStepDefinition(bindingSourceMethod, stepDefinitionAttribute))
            {
                return;
            }

            foreach (var stepDefinitionType in stepDefinitionTypes)
            {
                var stepDefinitionBinding = bindingFactory.CreateStepBinding(stepDefinitionType, regex, bindingSourceMethod.BindingMethod, scope);
                ProcessStepDefinitionBinding(stepDefinitionBinding);
            }
        }
 private void ApplyForScope(BindingScope[] scopes, Action<BindingScope> action)
 {
     if (scopes.Any())
     {
         foreach (var scope in scopes)
         {
             action(scope);
         }
     }
     else
     {
         action(null);
     }
 }
        public void TestBindingToMonthCalendar()
        {
            MonthCalendar control = new MonthCalendar();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                MonthCalendar bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeMaxSelectionCount = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxSelectionCount);

                Assert.AreEqual(dataBindingsBeforeMaxSelectionCount + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MaxSelectionCount, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MaxSelectionCount, obj.IntValue);

                int dataBindingsBeforeScrollChange = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.ScrollChange);

                Assert.AreEqual(dataBindingsBeforeScrollChange + 1, control.DataBindings.Count);

                Assert.AreEqual(control.ScrollChange, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.ScrollChange, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

            }
        }
        public void TestBindingToContainerControl()
        {
            ContainerControl control = new ContainerControl();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                ContainerControl bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeHeight = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Height);

                Assert.AreEqual(dataBindingsBeforeHeight + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Height, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Height, obj.IntValue);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        public void TestBindingToTrackBar()
        {
            TrackBar control = new TrackBar();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                TrackBar bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeLargeChange = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.LargeChange);

                Assert.AreEqual(dataBindingsBeforeLargeChange + 1, control.DataBindings.Count);

                Assert.AreEqual(control.LargeChange, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.LargeChange, obj.IntValue);

                int dataBindingsBeforeMaximum = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Maximum);

                Assert.AreEqual(dataBindingsBeforeMaximum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Maximum, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Maximum, obj.IntValue);

                int dataBindingsBeforeMinimum = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Minimum);

                Assert.AreEqual(dataBindingsBeforeMinimum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Minimum, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Minimum, obj.IntValue);

                int dataBindingsBeforeSmallChange = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SmallChange);

                Assert.AreEqual(dataBindingsBeforeSmallChange + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SmallChange, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SmallChange, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeTickFrequency = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TickFrequency);

                Assert.AreEqual(dataBindingsBeforeTickFrequency + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TickFrequency, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TickFrequency, obj.IntValue);

                int dataBindingsBeforeValue = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Value);

                Assert.AreEqual(dataBindingsBeforeValue + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Value, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Value, obj.IntValue);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        public void TestBindingToToolStripDropDownMenu()
        {
            ToolStripDropDownMenu control = new ToolStripDropDownMenu();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                ToolStripDropDownMenu bindableTarget = scope.CreateTarget(control);

            }
        }
        public void TestBindingToComboBox()
        {
            ComboBox control = new ComboBox();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                ComboBox bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeDropDownWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.DropDownWidth);

                Assert.AreEqual(dataBindingsBeforeDropDownWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.DropDownWidth, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.DropDownWidth, obj.IntValue);

                int dataBindingsBeforeDropDownHeight = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.DropDownHeight);

                Assert.AreEqual(dataBindingsBeforeDropDownHeight + 1, control.DataBindings.Count);

                Assert.AreEqual(control.DropDownHeight, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.DropDownHeight, obj.IntValue);

                int dataBindingsBeforeMaxDropDownItems = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxDropDownItems);

                Assert.AreEqual(dataBindingsBeforeMaxDropDownItems + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MaxDropDownItems, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MaxDropDownItems, obj.IntValue);

                int dataBindingsBeforeMaxLength = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxLength);

                Assert.AreEqual(dataBindingsBeforeMaxLength + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeDisplayMember = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.DisplayMember);

                Assert.AreEqual(dataBindingsBeforeDisplayMember + 1, control.DataBindings.Count);

                Assert.AreEqual(control.DisplayMember, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.DisplayMember, obj.Name);

                int dataBindingsBeforeFormatString = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.FormatString);

                Assert.AreEqual(dataBindingsBeforeFormatString + 1, control.DataBindings.Count);

                Assert.AreEqual(control.FormatString, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.FormatString, obj.Name);

                int dataBindingsBeforeValueMember = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.ValueMember);

                Assert.AreEqual(dataBindingsBeforeValueMember + 1, control.DataBindings.Count);

                Assert.AreEqual(control.ValueMember, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.ValueMember, obj.Name);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        public void TestBindingToRichTextBox()
        {
            RichTextBox control = new RichTextBox();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                RichTextBox bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeBulletIndent = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.BulletIndent);

                Assert.AreEqual(dataBindingsBeforeBulletIndent + 1, control.DataBindings.Count);

                Assert.AreEqual(control.BulletIndent, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.BulletIndent, obj.IntValue);

                int dataBindingsBeforeMaxLength = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxLength);

                Assert.AreEqual(dataBindingsBeforeMaxLength + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                int dataBindingsBeforeRightMargin = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.RightMargin);

                Assert.AreEqual(dataBindingsBeforeRightMargin + 1, control.DataBindings.Count);

                Assert.AreEqual(control.RightMargin, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.RightMargin, obj.IntValue);

                int dataBindingsBeforeSelectionCharOffset = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionCharOffset);

                Assert.AreEqual(dataBindingsBeforeSelectionCharOffset + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionCharOffset, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionCharOffset, obj.IntValue);

                int dataBindingsBeforeSelectionHangingIndent = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionHangingIndent);

                Assert.AreEqual(dataBindingsBeforeSelectionHangingIndent + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionHangingIndent, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionHangingIndent, obj.IntValue);

                int dataBindingsBeforeSelectionIndent = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionIndent);

                Assert.AreEqual(dataBindingsBeforeSelectionIndent + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionIndent, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionIndent, obj.IntValue);

                int dataBindingsBeforeSelectionRightIndent = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionRightIndent);

                Assert.AreEqual(dataBindingsBeforeSelectionRightIndent + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionRightIndent, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionRightIndent, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeZoomFactor = control.DataBindings.Count;

                scope.Bind(bindableSource.FloatValue).To(bindableTarget.ZoomFactor);

                Assert.AreEqual(dataBindingsBeforeZoomFactor + 1, control.DataBindings.Count);

                Assert.AreEqual(control.ZoomFactor, obj.FloatValue);

                obj.ChangeFloatValue();

                Assert.AreEqual(control.ZoomFactor, obj.FloatValue);

                int dataBindingsBeforeHeight = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Height);

                Assert.AreEqual(dataBindingsBeforeHeight + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Height, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Height, obj.IntValue);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        public void TestBindingToProgressBar()
        {
            ProgressBar control = new ProgressBar();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                ProgressBar bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeMarqueeAnimationSpeed = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MarqueeAnimationSpeed);

                Assert.AreEqual(dataBindingsBeforeMarqueeAnimationSpeed + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MarqueeAnimationSpeed, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MarqueeAnimationSpeed, obj.IntValue);

                int dataBindingsBeforeMaximum = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Maximum);

                Assert.AreEqual(dataBindingsBeforeMaximum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Maximum, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Maximum, obj.IntValue);

                int dataBindingsBeforeMinimum = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Minimum);

                Assert.AreEqual(dataBindingsBeforeMinimum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Minimum, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Minimum, obj.IntValue);

                int dataBindingsBeforeStep = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Step);

                Assert.AreEqual(dataBindingsBeforeStep + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Step, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Step, obj.IntValue);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeValue = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Value);

                Assert.AreEqual(dataBindingsBeforeValue + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Value, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Value, obj.IntValue);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeHeight = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Height);

                Assert.AreEqual(dataBindingsBeforeHeight + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Height, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Height, obj.IntValue);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        private void ProcessHookAttribute(BindingSourceMethod bindingSourceMethod, BindingSourceAttribute hookAttribute, BindingScope scope)
        {
            HookType hookType = GetHookType(hookAttribute);

            if (!ValidateHook(bindingSourceMethod, hookAttribute, hookType))
                return;

            var hookBinding = bindingFactory.CreateHookBinding(bindingSourceMethod.BindingMethod, hookType, scope);

            ProcessHookBinding(hookBinding);
        }
        private void ProcessStepDefinitionAttribute(BindingSourceMethod bindingSourceMethod, BindingSourceAttribute stepDefinitionAttribute, BindingScope scope)
        {
            var stepDefinitionTypes = GetStepDefinitionTypes(stepDefinitionAttribute);
            string regex = stepDefinitionAttribute.TryGetAttributeValue<string>(0);

            if (!ValidateStepDefinition(bindingSourceMethod, stepDefinitionAttribute))
                return;

            foreach (var stepDefinitionType in stepDefinitionTypes)
            {
                var stepDefinitionBinding = bindingFactory.CreateStepBinding(stepDefinitionType, regex, bindingSourceMethod.BindingMethod, scope);
                ProcessStepDefinitionBinding(stepDefinitionBinding);
            }
        }
 public BindingDefinition(Type serviceType, Type implementationType, BindingScope scope)
 {
     this.ServiceType        = serviceType;
     this.ImplementationType = implementationType;
     this.Scope = scope;
 }
Example #51
0
 public BindAttribute(BindingScope scope=BindingScope.GameObject, BindingDefault ifNotFound = BindingDefault.Exception)
 {
     IfNotFound = ifNotFound;
     Scope = scope;
 }
 protected virtual void ProcessStepDefinitions(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     foreach (var stepDefinitionAttribute in bindingSourceMethod.Attributes.Where(IsStepDefinitionAttribute))
     {
         ProcessStepDefinitionAttribute(bindingSourceMethod, methodScopes, stepDefinitionAttribute);
     }
 }
Example #53
0
        private void ProcessHookAttribute(BindingSourceMethod bindingSourceMethod, BindingSourceAttribute hookAttribute, BindingScope scope)
        {
            HookType hookType = GetHookType(hookAttribute);
            int      order    = GetHookOrder(hookAttribute);

            if (!ValidateHook(bindingSourceMethod, hookAttribute, hookType))
            {
                return;
            }

            var hookBinding = bindingFactory.CreateHookBinding(bindingSourceMethod.BindingMethod, hookType, scope, order);

            ProcessHookBinding(hookBinding);
        }
 protected virtual void ProcessHooks(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     foreach (var hookAttribute in bindingSourceMethod.Attributes.Where(IsHookAttribute))
     {
         ProcessHookAttribute(bindingSourceMethod, methodScopes, hookAttribute);
     }
 }
Example #55
0
 public ScopeAttribute(BindingScope scope)
 {
     Scope = scope;
 }
 protected virtual void ProcessStepArgumentTransformations(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     foreach (var stepArgumentTransformationAttribute in bindingSourceMethod.Attributes.Where(IsStepArgumentTransformationAttribute))
     {
         ProcessStepArgumentTransformationAttribute(bindingSourceMethod, stepArgumentTransformationAttribute);
     }
 }
Example #57
0
        /// <summary>
        /// By default, we are configured to use MEF
        /// </summary>
        protected override void Configure()
        {
            try
            {
                var splashScreen = new SplashScreen(Assembly.GetAssembly(typeof(AppBootstrapper)), "daxstudio-splash.png");
                splashScreen.Show(true);

                // Tell Caliburn Micro how to find controls in Fluent Ribbon

                /*
                 * defaultElementLookup = BindingScope.GetNamedElements;
                 * BindingScope.GetNamedElements = new Func<System.Windows.DependencyObject, IEnumerable<System.Windows.FrameworkElement>>(
                 *  k =>
                 *  {
                 *      List<FrameworkElement> namedElements = new List<FrameworkElement>();
                 *      namedElements.AddRange(defaultElementLookup(k));
                 *      Fluent.Ribbon ribbon = LookForRibbon(k);
                 *      if (null != ribbon)
                 *          AppendRibbonNamedItem(ribbon, namedElements);
                 *      return namedElements;
                 *  }
                 *  );
                 */

                ConventionManager.AddElementConvention <Fluent.Spinner>(Fluent.Spinner.ValueProperty, "Value", "ValueChanged");

                // TODO - do I need to replace these conventions ??
                //ConventionManager.AddElementConvention<NumericUpDownLib.DoubleUpDown>(NumericUpDownLib.DoubleUpDown.ValueProperty, "Value", "ValueChanged");

                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.DoubleUpDown>(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, "Value", "ValueChanged");
                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.IntegerUpDown>(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, "Value", "ValueChanged");
                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.WatermarkTextBox>(Xceed.Wpf.Toolkit.WatermarkTextBox.TextProperty, "Text", "TextChanged");

                // Add Fluent Ribbon resovler
                BindingScope.AddChildResolver <Fluent.Ribbon>(FluentRibbonChildResolver);


                // Fixes the default datetime format in the results listview
                // from: http://stackoverflow.com/questions/1993046/datetime-region-specific-formatting-in-wpf-listview
                FrameworkElement.LanguageProperty.OverrideMetadata(
                    typeof(FrameworkElement),
                    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

                var catalog = new AggregateCatalog(
                    AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType <ComposablePartCatalog>()
                    );
                //_container = new CompositionContainer(catalog,true);
                _container = new CompositionContainer(catalog);
                var batch = new CompositionBatch();



                batch.AddExportedValue <IWindowManager>(new WindowManager());
                batch.AddExportedValue <IEventAggregator>(new EventAggregator());
                batch.AddExportedValue <Func <DocumentViewModel> >(() => _container.GetExportedValue <DocumentViewModel>());
                batch.AddExportedValue <Func <IWindowManager, IEventAggregator, DocumentViewModel> >(
                    (w, e) => _container.GetExportedValue <DocumentViewModel>());
                batch.AddExportedValue(_container);
                batch.AddExportedValue(catalog);

                ISettingProvider settingProvider = SettingsProviderFactory.GetSettingProvider();

                batch.AddExportedValue <ISettingProvider>(settingProvider);

                _container.Compose(batch);

                // Add AvalonDock binding convetions
                AvalonDockConventions.Install();

                //var settingFactory = _container.GetExport<Func<ISettingProvider>>();



                ConfigureKeyBindingConvention();

                // TODO - not working
                //VisibilityBindingConvention.Install();

                // Enable Caliburn.Micro debug logging
                //LogManager.GetLog = type => new DebugLogger(type);

                // Add Application object to MEF catalog
                _container.ComposeExportedValue <Application>("System.Windows.Application", Application.Current);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
 private void ProcessStepDefinitionAttribute(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes, BindingSourceAttribute stepDefinitionAttribute)
 {
     ApplyForScope(methodScopes, scope => ProcessStepDefinitionAttribute(bindingSourceMethod, stepDefinitionAttribute, scope));
 }
        public void TestBindingToMaskedTextBox()
        {
            MaskedTextBox control = new MaskedTextBox();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                MaskedTextBox bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeMask = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Mask);

                Assert.AreEqual(dataBindingsBeforeMask + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Mask, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Mask, obj.Name);

                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
        public void TestBindingToNumericUpDown()
        {
            NumericUpDown control = new NumericUpDown();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                NumericUpDown bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeDecimalPlaces = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.DecimalPlaces);

                Assert.AreEqual(dataBindingsBeforeDecimalPlaces + 1, control.DataBindings.Count);

                Assert.AreEqual(control.DecimalPlaces, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.DecimalPlaces, obj.IntValue);

                int dataBindingsBeforeIncrement = control.DataBindings.Count;

                scope.Bind(bindableSource.DecimalValue).To(bindableTarget.Increment);

                Assert.AreEqual(dataBindingsBeforeIncrement + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Increment, obj.DecimalValue);

                obj.ChangeDecimalValue();

                Assert.AreEqual(control.Increment, obj.DecimalValue);

                int dataBindingsBeforeMaximum = control.DataBindings.Count;

                scope.Bind(bindableSource.DecimalValue).To(bindableTarget.Maximum);

                Assert.AreEqual(dataBindingsBeforeMaximum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Maximum, obj.DecimalValue);

                obj.ChangeDecimalValue();

                Assert.AreEqual(control.Maximum, obj.DecimalValue);

                int dataBindingsBeforeMinimum = control.DataBindings.Count;

                scope.Bind(bindableSource.DecimalValue).To(bindableTarget.Minimum);

                Assert.AreEqual(dataBindingsBeforeMinimum + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Minimum, obj.DecimalValue);

                obj.ChangeDecimalValue();

                Assert.AreEqual(control.Minimum, obj.DecimalValue);

                int dataBindingsBeforeValue = control.DataBindings.Count;

                scope.Bind(bindableSource.DecimalValue).To(bindableTarget.Value);

                Assert.AreEqual(dataBindingsBeforeValue + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Value, obj.DecimalValue);

                obj.ChangeDecimalValue();

                Assert.AreEqual(control.Value, obj.DecimalValue);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }