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

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

            result.ShouldBe(default);
Ejemplo n.º 2
0
        public async Task Test002()
        {
            var identifier = "test";
            var handler    = new MockJsRuntimeInvokeHandler();
            await handler.ToJsRuntime().InvokeVoidAsync(identifier);

            Should.Throw <JsInvokeCountExpectedException>(() => handler.VerifyNotInvoke(identifier));
        }
Ejemplo n.º 3
0
        public async Task Test003()
        {
            var identifier = "test";
            var errMsg     = "HELLO WORLD";
            var handler    = new MockJsRuntimeInvokeHandler();
            await handler.ToJsRuntime().InvokeVoidAsync(identifier);

            Should.Throw <JsInvokeCountExpectedException>(() => handler.VerifyNotInvoke(identifier, errMsg))
            .Message.ShouldContain(errMsg);
        }
Ejemplo n.º 4
0
        public async Task Test103()
        {
            var identifier = "test";
            var handler    = new MockJsRuntimeInvokeHandler();
            await handler.ToJsRuntime().InvokeVoidAsync(identifier);

            var actual = Should.Throw <JsInvokeCountExpectedException>(() => handler.VerifyInvoke(identifier, 2));

            actual.ExpectedInvocationCount.ShouldBe(2);
            actual.ActualInvocationCount.ShouldBe(1);
            actual.Identifier.ShouldBe(identifier);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        public async Task Test104()
        {
            var identifier = "test";
            var handler    = new MockJsRuntimeInvokeHandler();
            await handler.ToJsRuntime().InvokeVoidAsync(identifier);

            var invocations = handler.VerifyInvoke(identifier, 1);

            invocations.ShouldBeSameAs(handler.Invocations[identifier]);

            var invocation = handler.VerifyInvoke(identifier);

            invocation.ShouldBe(handler.Invocations[identifier][0]);
        }