public void BuildInnerExpressionPath() { //Property to set System.Reflection.PropertyInfo prop = typeof(FakeRecipient).GetProperty("StringProperty"); //expression and binding item string expr = "Root.Value"; BindingItemExpression itembind = BindingItemExpression.Create(expr, prop); //Set the items value to be extracted as an inner property on the source PDFDataBindEventArgs args = CreateDataBindArgs(); string expected = "This is the test"; FakeSource root = new FakeSource(); root.Value = expected; args.Context.Items["Root"] = root; //bind the recipient - should have its property set to the item value FakeRecipient recip = new FakeRecipient(); itembind.BindComponent(recip, args); string actual = recip.StringProperty; Assert.AreEqual(expected, actual); }
public void BuildInnerDynamicExpressionPath() { string expected = "This is a dynamic property value"; dynamic data = new ExpandoObject(); data.MyProperty = expected; //expression and binding item string expr = "Dynamic.MyProperty"; //Property to set System.Reflection.PropertyInfo prop = typeof(FakeRecipient).GetProperty("StringProperty"); //Create the expression binding BindingItemExpression itembind = BindingItemExpression.Create(expr, prop); //Set the items value to be extracted as an inner property on the source PDFDataBindEventArgs args = CreateDataBindArgs(); //Set the root entry to the top of the object braph args.Context.Items["Dynamic"] = data; //bind the recipient - should have its property set to the item value FakeRecipient recip = new FakeRecipient(); itembind.BindComponent(recip, args); //String Property should be set to the expected value string actual = recip.StringProperty; Assert.AreEqual(expected, actual); // // with string indexing // expected = "This is another dynamic property value"; data.MyProperty = expected; //Create the expression binding expr = "Dynamic['MyProperty']"; itembind = BindingItemExpression.Create(expr, prop); //Set the items value to be extracted as an inner property on the source args = CreateDataBindArgs(); //Set the root entry to the top of the object braph args.Context.Items["Dynamic"] = data; //bind the recipient - should have its property set to the item value recip = new FakeRecipient(); itembind.BindComponent(recip, args); //String Property should be set to the expected value actual = recip.StringProperty; Assert.AreEqual(expected, actual); }
public void BuildInnerInnerKeyedExpressionPath() { //Build the object graph string expected = "This is the test"; FakeSource innerinner = new FakeSource(); innerinner.Value = expected; FakeSource inner = new FakeSource(); inner.Keys = new Dictionary <string, FakeSource>(); inner.Keys["First"] = innerinner; FakeSource root = new FakeSource(); root.Items = new List <FakeSource>(); root.Items.Add(null); root.Items.Add(inner); //expression and binding item string expr = "Root.Items[1].Keys['First'].Value"; //Property to set System.Reflection.PropertyInfo prop = typeof(FakeRecipient).GetProperty("StringProperty"); //Create the expression binding BindingItemExpression itembind = BindingItemExpression.Create(expr, prop); //Set the items value to be extracted as an inner property on the source PDFDataBindEventArgs args = CreateDataBindArgs(); //Set the root entry to the top of the object braph args.Context.Items["Root"] = root; //bind the recipient - should have its property set to the item value FakeRecipient recip = new FakeRecipient(); itembind.BindComponent(recip, args); //String Property should be set to the expected value string actual = recip.StringProperty; Assert.AreEqual(expected, actual); }
public void BuildNotSetExpressionPath() { //Property to set System.Reflection.PropertyInfo prop = typeof(FakeRecipient).GetProperty("StringProperty"); //expression and binding item string expr = "Root"; BindingItemExpression itembind = BindingItemExpression.Create(expr, prop); //DO NOT Set the items value to be extracted PDFDataBindEventArgs args = CreateDataBindArgs(); //string expected = "This is the test"; //args.Context.Items["Root"] = expected; //bind the recipient - should have its property set to the item value FakeRecipient recip = new FakeRecipient(); itembind.BindComponent(recip, args); string actual = recip.StringProperty; Assert.IsNull(actual); }