public async Task Given_function_code_And_configured_to_run_in_ui_thread_When_Minimizing_Then_should_evaluate_function_with_parameters() { Setup(); await _unit.Minimize(new[] { 1.23, 4.56 }); _mock.Verify(m => m.InvokeAsync <double>("BlazorDynamicJavascriptRuntime.evaluate", It.Is <object[]>(p => p[0].ToString() == _formatted))); }
public async Task Given_function_code_And_configured_to_run_in_ui_thread_When_Minimizing_Then_should_evaluate_function_with_parameters() { var mock = new Mock <IJSRuntime>(); var formatted = Code + "\r\nabc(1.23,4.56);"; mock.Setup(m => m.InvokeAsync <double>(formatted, It.IsAny <object[]>())).Returns(new ValueTask <double>(Task.FromResult(7.89))); var unit = new JavascriptOptimizer(mock.Object, new BlazorClientConfiguration { EnableOptimizerWorker = false }); unit.Initialize(Code, Mock.Of <IActivityLogger>()); await unit.Minimize(new[] { 1.23, 4.56 }); mock.Verify(m => m.InvokeAsync <double>("BlazorDynamicJavascriptRuntime.evaluate", It.Is <object[]>(p => p[0].ToString() == formatted))); }