Class BunitJSInteropSetupExtensions
- Namespace
- Bunit
- Assembly
- Bunit.Web.dll
Helper methods for creating invocation handlers and adding the to a BunitJSInterop.
public static class BunitJSInteropSetupExtensions
- Inheritance
-
BunitJSInteropSetupExtensions
- Inherited Members
Methods
SetupModule(BunitJSInterop)
Configure a catch all JSObjectReferenceInvocationHandler invocation handler for any module load and invocations on those modules.
public static BunitJSModuleInterop SetupModule(this BunitJSInterop jsInterop)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
Returns
Remarks
The returned BunitJSInterop can be used to setup handlers for
InvokeAsync<TValue>(string, object?[]?)"
calls to the module, using either
SetupModule(BunitJSInterop, string) or Setup calls.
Exceptions
- ArgumentNullException
Thrown when
jsInterop
is null.
SetupModule(BunitJSInterop, InvocationMatcher, bool)
Setup a handler for a IJSRuntime.InvokeAsync<IJSObjectReference>()
call whose input parameters is matched by the provided
invocationMatcher
.
public static BunitJSModuleInterop SetupModule(this BunitJSInterop jsInterop, InvocationMatcher invocationMatcher, bool isCatchAllHandler = false)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
invocationMatcher
InvocationMatcherThe matcher to use to match JSRuntimeInvocation's with.
isCatchAllHandler
boolSet to true if the created handler is a catch all handler, that should only be used if there are no other non-catch all handlers available.
Returns
Remarks
The returned BunitJSInterop can be used to setup handlers for
InvokeAsync<TValue>(string, object?[]?)"
calls to the module, using either
SetupModule(BunitJSInterop, string) or Setup calls.
Exceptions
- ArgumentNullException
Thrown when
jsInterop
is null.- ArgumentNullException
Thrown when
invocationMatcher
is null.
SetupModule(BunitJSInterop, string)
Setup a handler for a IJSRuntime.InvokeAsync<IJSObjectReference>("import",
call.moduleName
)
public static BunitJSModuleInterop SetupModule(this BunitJSInterop jsInterop, string moduleName)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
moduleName
stringThe name of the JavaScript module to handle invocations for.
Returns
Remarks
The returned BunitJSInterop can be used to setup handlers for
InvokeAsync<TValue>(string, object?[]?)"
calls to the module, using either
SetupModule(BunitJSInterop, string) or Setup calls.
Exceptions
- ArgumentNullException
Thrown when
jsInterop
is null.- ArgumentException
Thrown when
moduleName
is null or whitespace.
SetupModule(BunitJSInterop, string, InvocationMatcher)
Setup a handler for a IJSRuntime.InvokeAsync<IJSObjectReference>()
call whose input parameters is matched by the provided
invocationMatcher
and the identifier
.
public static BunitJSModuleInterop SetupModule(this BunitJSInterop jsInterop, string identifier, InvocationMatcher invocationMatcher)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
identifier
stringThe identifier to setup a response for.
invocationMatcher
InvocationMatcherThe matcher to use to match JSRuntimeInvocation's with.
Returns
Remarks
The returned BunitJSInterop can be used to setup handlers for
InvokeAsync<TValue>(string, object?[]?)"
calls to the module, using either
SetupModule(BunitJSInterop, string) or Setup calls.
Exceptions
- ArgumentNullException
Thrown when
jsInterop
is null.- ArgumentNullException
Thrown when
invocationMatcher
is null.
SetupModule(BunitJSInterop, string, object?[])
Setup a handler for a IJSRuntime.InvokeAsync<IJSObjectReference>(
call.identifier
, arguments
)
public static BunitJSModuleInterop SetupModule(this BunitJSInterop jsInterop, string identifier, object?[] arguments)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
identifier
stringThe identifier to setup a response for.
arguments
object[]The arguments that an invocation to
identifier
should match. UseArray.Empty<object?>()
for none.
Returns
Remarks
The returned BunitJSInterop can be used to setup handlers for
InvokeAsync<TValue>(string, object?[]?)"
calls to the module, using either
SetupModule(BunitJSInterop, string) or Setup calls.
Exceptions
- ArgumentNullException
Thrown when
jsInterop
is null.- ArgumentException
Thrown when
identifier
is null or whitespace.
SetupVoid(BunitJSInterop)
Configure a catch all JSInterop invocation handler, that should not receive any result.
public static JSRuntimeInvocationHandler SetupVoid(this BunitJSInterop jsInterop)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
Returns
SetupVoid(BunitJSInterop, InvocationMatcher, bool)
Configure a JSInterop invocation handler for an InvokeVoidAsync
call with arguments
passing the invocationMatcher
test, that should not receive any result.
public static JSRuntimeInvocationHandler SetupVoid(this BunitJSInterop jsInterop, InvocationMatcher invocationMatcher, bool isCatchAllHandler = false)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
invocationMatcher
InvocationMatcherA matcher that is passed an JSRuntimeInvocation. If it returns true the invocation is matched.
isCatchAllHandler
boolSet to true if the created handler is a catch all handler, that should only be used if there are no other non-catch all handlers available.
Returns
SetupVoid(BunitJSInterop, string, InvocationMatcher)
Configure a JSInterop invocation handler with the identifier
and arguments
passing the invocationMatcher
test, that should not receive any result.
public static JSRuntimeInvocationHandler SetupVoid(this BunitJSInterop jsInterop, string identifier, InvocationMatcher invocationMatcher)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier to setup a response for.
invocationMatcher
InvocationMatcherA matcher that is passed an JSRuntimeInvocation associated with the
identifier
. If it returns true the invocation is matched.
Returns
SetupVoid(BunitJSInterop, string, params object?[]?)
Configure a JSInterop invocation handler with the identifier
and arguments
, that should not receive any result.
public static JSRuntimeInvocationHandler SetupVoid(this BunitJSInterop jsInterop, string identifier, params object?[]? arguments)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier to setup a response for.
arguments
object[]The arguments that an invocation to
identifier
should match.
Returns
Setup<TResult>(BunitJSInterop)
Configure a catch all JSInterop invocation handler for a specific return type.
This will match only on the TResult
, and any arguments passed to
InvokeAsync<TValue>(string, object[]).
public static JSRuntimeInvocationHandler<TResult> Setup<TResult>(this BunitJSInterop jsInterop)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
Returns
Type Parameters
TResult
The result type of the invocation.
Setup<TResult>(BunitJSInterop, InvocationMatcher, bool)
Configure a JSInterop invocation handler for an InvokeAsync<TResult>
call with arguments
passing the invocationMatcher
test.
public static JSRuntimeInvocationHandler<TResult> Setup<TResult>(this BunitJSInterop jsInterop, InvocationMatcher invocationMatcher, bool isCatchAllHandler = false)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
invocationMatcher
InvocationMatcherA matcher that is passed an JSRuntimeInvocation. If it returns true the invocation is matched.
isCatchAllHandler
boolSet to true if the created handler is a catch all handler, that should only be used if there are no other non-catch all handlers available.
Returns
Type Parameters
TResult
The result type of the invocation.
Setup<TResult>(BunitJSInterop, string, InvocationMatcher)
Configure a JSInterop invocation handler with the identifier
and arguments
passing the invocationMatcher
test.
public static JSRuntimeInvocationHandler<TResult> Setup<TResult>(this BunitJSInterop jsInterop, string identifier, InvocationMatcher invocationMatcher)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier to setup a response for.
invocationMatcher
InvocationMatcherA matcher that is passed an JSRuntimeInvocation associated with the
identifier
. If it returns true the invocation is matched.
Returns
Type Parameters
TResult
The result type of the invocation.
Setup<TResult>(BunitJSInterop, string, params object?[]?)
Configure a JSInterop invocation handler with the identifier
and arguments
.
public static JSRuntimeInvocationHandler<TResult> Setup<TResult>(this BunitJSInterop jsInterop, string identifier, params object?[]? arguments)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier to setup a response for.
arguments
object[]The arguments that an invocation to
identifier
should match.
Returns
Type Parameters
TResult
The type of value to match with in a InvokeAsync<TResult> call.
TryGetInvokeHandler<TResult>(BunitJSInterop, string, params object?[]?)
Looks through the registered handlers and returns the latest registered that can handle
the provided identifier
and arguments
, and that
will return TResult
.
public static JSRuntimeInvocationHandler<TResult>? TryGetInvokeHandler<TResult>(this BunitJSInterop jsInterop, string identifier, params object?[]? arguments)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier the handler should match with.
arguments
object[]The arguments that an invocation to
identifier
should match.
Returns
- JSRuntimeInvocationHandler<TResult>
Returns the JSRuntimeInvocationHandler<TResult> or null if no one is found.
Type Parameters
TResult
The result type of the invocation.
TryGetInvokeVoidHandler(BunitJSInterop, string, params object?[]?)
Looks through the registered handlers and returns the latest registered that can handle
the provided identifier
and arguments
, and that returns a "void" result.
public static JSRuntimeInvocationHandler? TryGetInvokeVoidHandler(this BunitJSInterop jsInterop, string identifier, params object?[]? arguments)
Parameters
jsInterop
BunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifier
stringThe identifier the handler should match with.
arguments
object[]The arguments that an invocation to
identifier
should match.
Returns
- JSRuntimeInvocationHandler
Returns the JSRuntimeInvocationHandler or null if no one is found.
TryGetModuleJSInterop(BunitJSInterop, string, params object?[]?)
Looks through the registered handlers and returns the latest registered that can handle
the provided identifier
and arguments
, and that
will return IJSObjectReference.
public static BunitJSModuleInterop? TryGetModuleJSInterop(this BunitJSInterop jsInterop, string identifier, params object?[]? arguments)
Parameters
jsInterop
BunitJSInteropThe JSInterop to setup the handler for.
identifier
stringThe identifier the handler should match with.
arguments
object[]The arguments that an invocation to
identifier
should match.
Returns
- BunitJSModuleInterop
A BunitJSModuleInterop or null if no one is found.