Example #1
0
        public void TestConvertAttachedBindableProperty()
        {
            var node     = new ValueNode("qux", new MockNameSpaceResolver());
            var bindable = new Bindable();

            Assert.IsNull(Bindable.GetQux(bindable));
            var rootNode = new XamlLoader.RuntimeRootNode(new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests", "Bindable", null), bindable, null)
            {
                Properties =
                {
                    { new XmlName("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests", "Bindable.Qux"), node },
                }
            };
            var context = new HydrationContext {
                RootElement = new Label()
            };

            rootNode.Accept(new CreateValuesVisitor(context), null);
            node.Accept(new ApplyPropertiesVisitor(context), rootNode);
            Assert.IsNotNull(Bindable.GetQux(bindable));
            Assert.That(Bindable.GetQux(bindable), Is.TypeOf <Qux>());
            Assert.AreEqual("qux", Bindable.GetQux(bindable).Value);
        }