Ejemplo n.º 1
0
        public void SimplePathTargetResolutionTest()
        {
            string      rawPath = "tb1.Text";
            BindingPath path    = new BindingPath(rawPath);

            TextBox tb = new TextBox();

            tb.ID   = "tb1";
            tb.Text = "hello";

            //tell the control service to return our control when asked
            controlService.Expect(cs => cs.FindControlUnique(null, null)).IgnoreArguments()
            .Do(new Func <IBindingTarget, string, IBindingTarget>((s, e) => new WebformControl(tb)));

            //and unwrap
            controlService.Expect(cs => cs.Unwrap(null)).IgnoreArguments().Do(new Func <IBindingTarget, object>(b => tb));

            TargetProperty targetProperty = path.ResolveAsTarget(new WebformControl(tb), this.controlService);

            Assert.IsNotNull(targetProperty);
            Assert.IsNotNull(targetProperty.Descriptor);
            Assert.IsNotNull(targetProperty.OwningControlRaw);
            Assert.IsNotNull(targetProperty.Value);

            Assert.AreEqual("hello", targetProperty.Value);
            Assert.AreEqual("Text", targetProperty.Descriptor.Name);
            Assert.AreEqual(tb, targetProperty.OwningControlRaw);
        }