Пример #1
0
        public void ShouldInvokeGetMemberOperationOnCustomDynamic()
        {
            dynamic dynamic = new TestDynamicMetaObjectProvider();
            var     context = new { Dynamic = dynamic };

            var execution = ExecuteTemplate("$dynamic.Fizz", context);

            Assert.That(execution.Output, Is.EqualTo("DMO GetMember: Fizz"));
        }
Пример #2
0
        public void ShouldInvokeInvokeMemberOperationOnCustomDynamic()
        {
            var dynamic = new TestDynamicMetaObjectProvider();
            var context = new { Dynamic = dynamic };

            var execution = ExecuteTemplate("$dynamic.Foo('hello')", context);

            Assert.That(execution.Output, Is.EqualTo("DMO InvokeMember Foo: (hello)"));
        }
Пример #3
0
        public void ShouldInvokeBinaryOperationOnCustomDynamicForBinaryExpression(string op, string opName)
        {
            var dynamic = new TestDynamicMetaObjectProvider();
            var context = new { Dynamic = dynamic };

            var execution = ExecuteTemplate($"#set($result = $dynamic {op} 1)", context);

            Assert.That(execution.Context.Keys, Contains.Item("result"));
            Assert.That(execution.Context["result"], Is.EqualTo($"DMO Binary {opName}: 1"));
        }
Пример #4
0
        public void ShouldInvokeSetMemberOperationOnCustomDynamic()
        {
            var dynamic = new TestDynamicMetaObjectProvider();
            var context = new { Dynamic = dynamic };

            ExecuteTemplate("#set($dynamic.Bar = 7.45)", context);

            Assert.That(dynamic.SetValues.Keys, Contains.Item("Bar"));
            Assert.That(dynamic.SetValues["Bar"], Is.EqualTo(7.45f));
        }
Пример #5
0
 public CustomDynamicMetaObject(Expression expression, TestDynamicMetaObjectProvider value)
     : base(expression, BindingRestrictions.Empty, value)
 {
     _customDynamic = value;
 }