MockContainerRuntime Class
Mock implementation of IContainerRuntime for testing basic submitting and processing of messages. If test specific logic is required, extend this class and add the logic there. For an example, take a look at MockContainerRuntimeForReconnection. \
To use, import via @fluidframework/test-runtime-utils/legacy
.
For more information about our API support guarantees, see here.
Signature
export declare class MockContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
Extends: TypedEventEmitter<IContainerRuntimeEvents>
Constructors
Constructor | Alerts | Description |
---|---|---|
(constructor)(dataStoreRuntime, factory, mockContainerRuntimeOptions, overrides) | Beta |
Constructs a new instance of the MockContainerRuntime class |
Properties
Property | Alerts | Modifiers | Type | Description |
---|---|---|---|---|
clientId | Beta |
string | ||
dataStoreRuntime | Beta |
readonly |
MockFluidDataStoreRuntime | |
deltaConnections | Deprecated , Beta |
readonly |
MockDeltaConnection[] | |
deltaManager | Beta |
readonly |
MockDeltaManager | |
factory | Beta |
readonly |
MockContainerRuntimeFactory | |
isDirty | Beta |
readonly |
boolean | |
outbox | Beta |
readonly |
IInternalMockRuntimeMessage[] | |
overrides | Beta |
optional , readonly |
{ minimumSequenceNumber?: number | undefined; } | undefined | |
pendingMessages | Beta |
readonly |
IMockContainerRuntimePendingMessage[] | |
runtimeOptions | Beta |
readonly |
Required<IMockContainerRuntimeOptions> | The runtime options this instance is using. See IMockContainerRuntimeOptions. |
Methods
Method | Alerts | Modifiers | Return Type | Description |
---|---|---|---|---|
addPendingMessage(content, localOpMetadata, clientSequenceNumber) | Beta |
void | ||
createDeltaConnection() | Deprecated , Beta |
MockDeltaConnection | ||
dirty() | Beta |
void | ||
finalizeIdRange(range) | Beta |
void | ||
flush() | Beta |
void | If flush mode is set to FlushMode.TurnBased, it will send all messages queued since the last time this method (or flushSomeMessages ) was called. Otherwise, calling the method does nothing. |
|
flushSomeMessages(numMessages) | Beta |
void | If flush mode is set to FlushMode.TurnBased, it will send the specified number of messages from the outbox queued since the last time this (or flush ) was called. Otherwise, calling the method does nothing. This can be useful when simulating staging mode, and we only want to flush certain messages. |
|
maybeProcessIdAllocationMessage(message) | Beta |
boolean | If the message is an idAllocation message, it will finalize the id range and return true. Otherwise, it will return false. | |
process(message) | Beta |
void | ||
processInternal(message) | Beta |
[boolean, unknown] | ||
rebase() | Beta |
void |
If flush mode is set to FlushMode.TurnBased, it will rebase the current batch by resubmitting them to the data stores. Otherwise, calling the method does nothing. The method requires |
|
resolveHandle(handle) | Beta |
Promise<IResponse> | ||
reSubmitMessages(messagesToResubmit) | Beta |
void | ||
rollback() | Beta |
optional |
void | Rolls back all pending messages. |
runWithManualFlush(act) | Beta |
Promise<void> | ||
submit(messageContent, localOpMetadata) | Beta |
number |
Constructor Details
(constructor)
Constructs a new instance of the MockContainerRuntime
class
For more information about our API support guarantees, see here.
Signature
constructor(dataStoreRuntime: MockFluidDataStoreRuntime, factory: MockContainerRuntimeFactory, mockContainerRuntimeOptions?: IMockContainerRuntimeOptions, overrides?: {
minimumSequenceNumber?: number | undefined;
} | undefined);
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
dataStoreRuntime | MockFluidDataStoreRuntime | ||
factory | MockContainerRuntimeFactory | ||
mockContainerRuntimeOptions | optional | IMockContainerRuntimeOptions | |
overrides | optional | { minimumSequenceNumber?: number | undefined; } | undefined |
Property Details
clientId
For more information about our API support guarantees, see here.
Signature
clientId: string;
Type: string
dataStoreRuntime
For more information about our API support guarantees, see here.
Signature
protected readonly dataStoreRuntime: MockFluidDataStoreRuntime;
Type: MockFluidDataStoreRuntime
deltaConnections
use the associated datastore to create the delta connection
For more information about our API support guarantees, see here.
Signature
protected readonly deltaConnections: MockDeltaConnection[];
Type: MockDeltaConnection[]
deltaManager
For more information about our API support guarantees, see here.
Signature
readonly deltaManager: MockDeltaManager;
Type: MockDeltaManager
factory
For more information about our API support guarantees, see here.
Signature
protected readonly factory: MockContainerRuntimeFactory;
Type: MockContainerRuntimeFactory
isDirty
For more information about our API support guarantees, see here.
Signature
get isDirty(): boolean;
Type: boolean
outbox
For more information about our API support guarantees, see here.
Signature
protected readonly outbox: IInternalMockRuntimeMessage[];
Type: IInternalMockRuntimeMessage[]
overrides
For more information about our API support guarantees, see here.
Signature
protected readonly overrides?: {
minimumSequenceNumber?: number | undefined;
} | undefined;
Type: { minimumSequenceNumber?: number | undefined; } | undefined
pendingMessages
For more information about our API support guarantees, see here.
Signature
protected readonly pendingMessages: IMockContainerRuntimePendingMessage[];
Type: IMockContainerRuntimePendingMessage[]
runtimeOptions
The runtime options this instance is using. See IMockContainerRuntimeOptions.
For more information about our API support guarantees, see here.
Signature
protected readonly runtimeOptions: Required<IMockContainerRuntimeOptions>;
Type: Required<IMockContainerRuntimeOptions>
Method Details
addPendingMessage
For more information about our API support guarantees, see here.
Signature
protected addPendingMessage(content: any, localOpMetadata: unknown, clientSequenceNumber: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
content | any | |
localOpMetadata | unknown | |
clientSequenceNumber | number |
createDeltaConnection
use the associated datastore to create the delta connection
For more information about our API support guarantees, see here.
Signature
createDeltaConnection(): MockDeltaConnection;
Returns
Return type: MockDeltaConnection
dirty
For more information about our API support guarantees, see here.
Signature
dirty(): void;
finalizeIdRange
For more information about our API support guarantees, see here.
Signature
finalizeIdRange(range: IdCreationRange): void;
Parameters
Parameter | Type | Description |
---|---|---|
range | IdCreationRange |
flush
If flush mode is set to FlushMode.TurnBased, it will send all messages queued since the last time this method (or flushSomeMessages
) was called. Otherwise, calling the method does nothing.
For more information about our API support guarantees, see here.
Signature
flush(): void;
flushSomeMessages
If flush mode is set to FlushMode.TurnBased, it will send the specified number of messages from the outbox queued since the last time this (or flush
) was called. Otherwise, calling the method does nothing. This can be useful when simulating staging mode, and we only want to flush certain messages.
For more information about our API support guarantees, see here.
Signature
flushSomeMessages(numMessages: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
numMessages | number |
maybeProcessIdAllocationMessage
If the message is an idAllocation message, it will finalize the id range and return true. Otherwise, it will return false.
For more information about our API support guarantees, see here.
Signature
protected maybeProcessIdAllocationMessage(message: ISequencedDocumentMessage): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
message | ISequencedDocumentMessage |
Returns
Return type: boolean
process
For more information about our API support guarantees, see here.
Signature
process(message: ISequencedDocumentMessage): void;
Parameters
Parameter | Type | Description |
---|---|---|
message | ISequencedDocumentMessage |
processInternal
For more information about our API support guarantees, see here.
Signature
protected processInternal(message: ISequencedDocumentMessage): [boolean, unknown];
Parameters
Parameter | Type | Description |
---|---|---|
message | ISequencedDocumentMessage |
Returns
Return type: [boolean, unknown]
rebase
If flush mode is set to FlushMode.TurnBased, it will rebase the current batch by resubmitting them to the data stores. Otherwise, calling the method does nothing.
The method requires runtimeOptions.enableGroupedBatching
to be enabled.
For more information about our API support guarantees, see here.
Signature
rebase(): void;
resolveHandle
For more information about our API support guarantees, see here.
Signature
resolveHandle(handle: IFluidHandle): Promise<IResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
handle | IFluidHandle |
Returns
Return type: Promise<IResponse>
reSubmitMessages
For more information about our API support guarantees, see here.
Signature
protected reSubmitMessages(messagesToResubmit: {
content: any;
localOpMetadata?: unknown;
}[]): void;
Parameters
Parameter | Type | Description |
---|---|---|
messagesToResubmit | { content: any; localOpMetadata?: unknown; }[] |
rollback
Rolls back all pending messages.
For more information about our API support guarantees, see here.
Signature
rollback?(): void;
Remarks
This only works when the FlushMode is not immediate as immediate flush mode send the ops to the mock runtime factory for processing/sequencing, and so those ops are no longer local, so not available for rollback.
runWithManualFlush
For more information about our API support guarantees, see here.
Signature
runWithManualFlush(act: () => void | Promise<void>): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
act | () => void | Promise<void> |
Returns
Return type: Promise<void>
submit
For more information about our API support guarantees, see here.
Signature
submit(messageContent: any, localOpMetadata?: unknown): number;
Parameters
Parameter | Modifiers | Type | Description |
---|---|---|---|
messageContent | any | ||
localOpMetadata | optional | unknown |
Returns
Return type: number