Exemplo n.º 1
0
        public void can_get_an_expando_object_to_act_as_an_interface()
        {
            dynamic expando = Build <ExpandoObject> .NewObject(
                Prop1 : "Test",
                Prop2 : 42L,
                Prop3 : Guid.NewGuid(),
                Meth1 : Return <bool> .Arguments <int>(it => it > 5)
                );

            IMyInterface myInterface = Impromptu.ActLike(expando);

            Assert.Equal("Test", myInterface.Prop1);
            Assert.Equal(true, myInterface.Meth1(10));
        }