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:Microsoft.Maui.Controls.Xaml.UnitTests;assembly=Microsoft.Maui.Controls.Xaml.UnitTests", "Bindable", null), bindable, null) { Properties = { { new XmlName("clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests;assembly=Microsoft.Maui.Controls.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); }
public void TestConvertBindableProperty() { var node = new ValueNode("bar", new MockNameSpaceResolver()); var bindable = new Bindable(); Assert.IsNull(bindable.Bar); 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(null, "Bar"), node }, } }; var context = new HydrationContext { RootElement = new Label() }; rootNode.Accept(new CreateValuesVisitor(context), null); node.Accept(new ApplyPropertiesVisitor(context), rootNode); Assert.IsNotNull(bindable.Bar); Assert.That(bindable.Bar, Is.TypeOf <Bar>()); Assert.AreEqual("bar", bindable.Bar.Value); }
public GraphNode ShowConstants(ValueNode node) => node.Accept(this);
public override GraphNode ToGraphNode(ValueNode node) => node.Accept(this).SetColor(ASTHelper.IsContant(node) ? ConstantColor : NonConstantColor);
public IEnumerable <StatementNode> Flatten(ValueNode node) => node.Accept(this);
public string Print(ValueNode node) => node.Accept(this);
public bool IsContant(ValueNode node) => node.Accept(this);
public bool IsName(ValueNode node) => node.Accept(this);
public void TestConvertWithAttributeOnType () { var node = new ValueNode ("foobar", new MockNameSpaceResolver()); var bindable = new Bindable (); Assert.IsNull (bindable.FooBar); 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 (null, "FooBar"), node }, } }; var context = new HydratationContext { RootElement = new Label () }; rootNode.Accept (new CreateValuesVisitor (context), null); node.Accept (new ApplyPropertiesVisitor (context), rootNode); Assert.IsNotNull (bindable.FooBar); Assert.That (bindable.FooBar, Is.TypeOf<FooBar> ()); Assert.AreEqual ("foobar", bindable.FooBar.Value); }
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 HydratationContext { 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); }
public void TestFailOnMissingOrWrongConverter () { var node = new ValueNode ("baz", new MockNameSpaceResolver()); var bindable = new Bindable (); Assert.IsNull (bindable.Baz); 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 (null, "Baz"), node }, } }; var context = new HydratationContext { RootElement = new Label () }; rootNode.Accept (new CreateValuesVisitor (context), null); Assert.Throws<XamlParseException>(()=> node.Accept (new ApplyPropertiesVisitor (context), rootNode)); }
public void TestSetPropertyWithoutConverter () { var baz = new Baz (); var node = new ValueNode (baz, new MockNameSpaceResolver()); var bindable = new Bindable (); Assert.IsNull (bindable.Baz); 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 (null, "Baz"), node }, } }; var context = new HydratationContext { RootElement = new Label () }; rootNode.Accept (new CreateValuesVisitor(context), null); node.Accept (new ApplyPropertiesVisitor (context), rootNode); Assert.AreEqual (baz, bindable.Baz); }