Example #1
0
        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 async Task Test002()
        {
            var identifier = "test";
            var handler    = new MockJsRuntimeInvokeHandler();
            await handler.ToJsRuntime().InvokeVoidAsync(identifier);

            Should.Throw <JsInvokeCountExpectedException>(() => handler.VerifyNotInvoke(identifier));
        }
        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))
            .UserMessage.ShouldEndWith(errMsg);
        }
        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);
        }
        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]);
        }