public async Task Test001() { var sut = new MockJsRuntimeInvokeHandler(JsRuntimeMockMode.Loose); var result = await sut.ToJsRuntime().InvokeAsync <object>("ident", Array.Empty <object>()); result.ShouldBe(default);
public static void VerifyNotInvoke(this MockJsRuntimeInvokeHandler handler, string identifier, string?userMessage = null) { if (handler is null) { throw new ArgumentNullException(nameof(handler)); } if (handler.Invocations.TryGetValue(identifier, out var invocations) && invocations.Count > 0) { throw new JsInvokeCountExpectedException(identifier, 0, invocations.Count, nameof(VerifyNotInvoke), userMessage); } }
public void Setup() { using (Context = new Bunit.TestContext()); //Context.Services.AddSingleton<BlazorBarcode2.SyncfusionService>(new BlazorBarcode2.SyncfusionService()); // Context.Services.AddMockJsRuntime(); Context.Services.AddSyncfusionBlazor(); mockJsRt = Context.Services.AddMockJsRuntime(); renderInvocation = mockJsRt.Setup <bool>("render"); renderInvocation.SetResult(true); }
public static IReadOnlyList <JsRuntimeInvocation> VerifyInvoke(this MockJsRuntimeInvokeHandler handler, string identifier, int calledTimes = 1, string?userMessage = null) { if (handler is null) { throw new ArgumentNullException(nameof(handler)); } if (calledTimes < 1) { throw new ArgumentException($"Use {nameof(VerifyNotInvoke)} to verify an identifier has not been invoked.", nameof(calledTimes)); } var invocations = handler.Invocations[identifier]; if (invocations.Count != calledTimes) { throw new JsInvokeCountExpectedException(identifier, calledTimes, invocations.Count, nameof(VerifyInvoke), userMessage); } return(invocations); }
public AlertTest2() { MockJsRuntime = Services.AddMockJsRuntime(); }
public static JsRuntimeInvocation VerifyInvoke(this MockJsRuntimeInvokeHandler handler, string identifier) => VerifyInvoke(handler, identifier, 1)[0];