public async Task Given_multiple_dynamic_expressions_When_invoked_And_reset_And_invoked_Then_should_execute_mutliple_evaluations() { var runtime = new Mock <IJSRuntime>(); var expected = "value"; SetupReturnValue <string>(runtime, expected, "instance.property"); using (dynamic context = new EvalContext(runtime.Object)) { var evalContext = (context as EvalContext); dynamic arg = new EvalContext(runtime.Object); evalContext.Expression = () => context.var_instance = arg.new_object(); await evalContext.InvokeAsync <dynamic>(); evalContext.Reset(); evalContext.Expression = () => context.instance.property = expected; await evalContext.InvokeAsync <dynamic>(); evalContext.Reset(); arg = new EvalContext(runtime.Object); evalContext.Expression = () => context.instance.property; var actual = await evalContext.InvokeAsync <string>(); Assert.Equal(expected, actual); } Verify(runtime, "var instance = new object()"); Verify(runtime, "instance.property = \"value\""); Verify <string>(runtime, "instance.property"); }
public void Given_a_dynamic_expression_And_a_declaration_When_invoked_Then_should_execute_evaluation() { var runtime = new Mock <IJSRuntime>(); using (dynamic context = new EvalContext(runtime.Object)) { dynamic arg = new EvalContext(runtime.Object); (context as EvalContext).Expression = () => context.var_instance = arg.new_object(); } Verify(runtime, "var instance = new object()"); }