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
jsInteropBunitJSInteropThe 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
jsInteropis 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
jsInteropBunitJSInteropThe JSInterop to setup the handler for.
invocationMatcherInvocationMatcherThe matcher to use to match JSRuntimeInvocation's with.
isCatchAllHandlerboolSet 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
jsInteropis null.- ArgumentNullException
Thrown when
invocationMatcheris 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
jsInteropBunitJSInteropThe JSInterop to setup the handler for.
moduleNamestringThe 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
jsInteropis null.- ArgumentException
Thrown when
moduleNameis 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
jsInteropBunitJSInteropThe JSInterop to setup the handler for.
identifierstringThe identifier to setup a response for.
invocationMatcherInvocationMatcherThe 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
jsInteropis null.- ArgumentNullException
Thrown when
invocationMatcheris 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
jsInteropBunitJSInteropThe JSInterop to setup the handler for.
identifierstringThe identifier to setup a response for.
argumentsobject[]The arguments that an invocation to
identifiershould 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
jsInteropis null.- ArgumentException
Thrown when
identifieris 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
jsInteropBunitJSInteropThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
invocationMatcherInvocationMatcherA matcher that is passed an JSRuntimeInvocation. If it returns true the invocation is matched.
isCatchAllHandlerboolSet 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier to setup a response for.
invocationMatcherInvocationMatcherA 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier to setup a response for.
argumentsobject[]The arguments that an invocation to
identifiershould 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
Returns
Type Parameters
TResultThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
invocationMatcherInvocationMatcherA matcher that is passed an JSRuntimeInvocation. If it returns true the invocation is matched.
isCatchAllHandlerboolSet 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
TResultThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier to setup a response for.
invocationMatcherInvocationMatcherA matcher that is passed an JSRuntimeInvocation associated with the
identifier. If it returns true the invocation is matched.
Returns
Type Parameters
TResultThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier to setup a response for.
argumentsobject[]The arguments that an invocation to
identifiershould match.
Returns
Type Parameters
TResultThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier the handler should match with.
argumentsobject[]The arguments that an invocation to
identifiershould match.
Returns
- JSRuntimeInvocationHandler<TResult>
Returns the JSRuntimeInvocationHandler<TResult> or null if no one is found.
Type Parameters
TResultThe 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
jsInteropBunitJSInteropThe bUnit JSInterop to setup the invocation handling with.
identifierstringThe identifier the handler should match with.
argumentsobject[]The arguments that an invocation to
identifiershould 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
jsInteropBunitJSInteropThe JSInterop to setup the handler for.
identifierstringThe identifier the handler should match with.
argumentsobject[]The arguments that an invocation to
identifiershould match.
Returns
- BunitJSModuleInterop
A BunitJSModuleInterop or null if no one is found.