public async Task Test001()
        {
            var sut = new MockJsRuntimeInvokeHandler(JsRuntimeMockMode.Loose);

            var result = await sut.ToJsRuntime().InvokeAsync <object>("ident", Array.Empty <object>());

            result.ShouldBe(default);
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public AlertTest2()
 {
     MockJsRuntime = Services.AddMockJsRuntime();
 }
Exemplo n.º 6
0
 public static JsRuntimeInvocation VerifyInvoke(this MockJsRuntimeInvokeHandler handler, string identifier) => VerifyInvoke(handler, identifier, 1)[0];