/// <summary> /// Creates a <see cref="MockJsRuntimeInvokeHandler"/>. /// </summary> /// <param name="mode">The <see cref="JsRuntimeMockMode"/> the handler should use.</param> public MockJsRuntimeInvokeHandler(JsRuntimeMockMode mode = JsRuntimeMockMode.Loose) { Mode = mode; }
/// <summary> /// Adds the <see cref="MockJsRuntimeInvokeHandler"/> to the <see cref="TestServiceProvider"/>. /// </summary> /// <returns>The added <see cref="MockJsRuntimeInvokeHandler"/>.</returns> public static MockJsRuntimeInvokeHandler AddMockJsRuntime(this TestServiceProvider serviceProvider, JsRuntimeMockMode mode = JsRuntimeMockMode.Loose) { if (serviceProvider is null) { throw new ArgumentNullException(nameof(serviceProvider)); } var result = new MockJsRuntimeInvokeHandler(mode); serviceProvider.AddSingleton(result.ToJsRuntime()); return(result); }