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")); }
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)")); }
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")); }
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)); }
public CustomDynamicMetaObject(Expression expression, TestDynamicMetaObjectProvider value) : base(expression, BindingRestrictions.Empty, value) { _customDynamic = value; }