Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library doesn't work with dynamic object #78

Open
PaulGrimshaw opened this issue Jun 13, 2017 · 0 comments
Open

Library doesn't work with dynamic object #78

PaulGrimshaw opened this issue Jun 13, 2017 · 0 comments

Comments

@PaulGrimshaw
Copy link

PaulGrimshaw commented Jun 13, 2017

I've written a test to replicate this problem - this would be really useful functionality for us.

        /// <summary>
        /// Testing with Dynamic object.
        /// </summary>
        [TestMethod]
        public void TestCompile_DynamicObject_RendersCorrectly() {
            FormatCompiler compiler = new FormatCompiler();
            const string format = @"Hello {{Name}}";
            Generator generator = compiler.Compile(format);

            dynamic obj = new TestDymnamic();
            Assert.AreEqual("Paul", obj.Name);
            string actual = generator.Render(obj);

            string expected = "Hello Paul";
            Assert.AreEqual(expected, actual, "The number was not passed to the formatter.");
        }

        private class TestDymnamic: DynamicObject {
            public override bool TryGetMember(GetMemberBinder binder, out object result) {
                result = "Paul";
                return true;
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant