Skip to main content

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.

This API is provided for existing users, but is not recommended for new users.

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

ConstructorAlertsDescription
(constructor)(dataStoreRuntime, factory, mockContainerRuntimeOptions, overrides)BetaConstructs a new instance of the MockContainerRuntime class

Properties

PropertyAlertsModifiersTypeDescription
clientIdBetastring
dataStoreRuntimeBetareadonlyMockFluidDataStoreRuntime
deltaConnectionsDeprecated, BetareadonlyMockDeltaConnection[]
deltaManagerBetareadonlyMockDeltaManager
factoryBetareadonlyMockContainerRuntimeFactory
isDirtyBetareadonlyboolean
outboxBetareadonlyIInternalMockRuntimeMessage[]
overridesBetaoptional, readonly{ minimumSequenceNumber?: number | undefined; } | undefined
pendingMessagesBetareadonlyIMockContainerRuntimePendingMessage[]
runtimeOptionsBetareadonlyRequired<IMockContainerRuntimeOptions>The runtime options this instance is using. See IMockContainerRuntimeOptions.

Methods

MethodAlertsModifiersReturn TypeDescription
addPendingMessage(content, localOpMetadata, clientSequenceNumber)Betavoid
createDeltaConnection()Deprecated, BetaMockDeltaConnection
dirty()Betavoid
finalizeIdRange(range)Betavoid
flush()BetavoidIf 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)BetavoidIf 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)BetabooleanIf the message is an idAllocation message, it will finalize the id range and return true. Otherwise, it will return false.
process(message)Betavoid
processInternal(message)Beta[boolean, unknown]
rebase()Betavoid

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.

resolveHandle(handle)BetaPromise<IResponse>
reSubmitMessages(messagesToResubmit)Betavoid
rollback()BetaoptionalvoidRolls back all pending messages.
runWithManualFlush(act)BetaPromise<void>
submit(messageContent, localOpMetadata)Betanumber

Constructor Details

(constructor)

Constructs a new instance of the MockContainerRuntime class

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

constructor(dataStoreRuntime: MockFluidDataStoreRuntime, factory: MockContainerRuntimeFactory, mockContainerRuntimeOptions?: IMockContainerRuntimeOptions, overrides?: {
minimumSequenceNumber?: number | undefined;
} | undefined);

Parameters

ParameterModifiersTypeDescription
dataStoreRuntimeMockFluidDataStoreRuntime
factoryMockContainerRuntimeFactory
mockContainerRuntimeOptionsoptionalIMockContainerRuntimeOptions
overridesoptional{ minimumSequenceNumber?: number | undefined; } | undefined

Property Details

clientId

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

clientId: string;

Type: string

dataStoreRuntime

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly dataStoreRuntime: MockFluidDataStoreRuntime;

Type: MockFluidDataStoreRuntime

deltaConnections

This API is deprecated and will be removed in a future release.

use the associated datastore to create the delta connection

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly deltaConnections: MockDeltaConnection[];

Type: MockDeltaConnection[]

deltaManager

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly deltaManager: MockDeltaManager;

Type: MockDeltaManager

factory

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly factory: MockContainerRuntimeFactory;

Type: MockContainerRuntimeFactory

isDirty

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get isDirty(): boolean;

Type: boolean

outbox

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly outbox: IInternalMockRuntimeMessage[];

Type: IInternalMockRuntimeMessage[]

overrides

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly overrides?: {
minimumSequenceNumber?: number | undefined;
} | undefined;

Type: { minimumSequenceNumber?: number | undefined; } | undefined

pendingMessages

This API is provided for existing users, but is not recommended for new users.

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.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly runtimeOptions: Required<IMockContainerRuntimeOptions>;

Type: Required<IMockContainerRuntimeOptions>

Method Details

addPendingMessage

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected addPendingMessage(content: any, localOpMetadata: unknown, clientSequenceNumber: number): void;

Parameters

ParameterTypeDescription
contentany
localOpMetadataunknown
clientSequenceNumbernumber

createDeltaConnection

This API is deprecated and will be removed in a future release.

use the associated datastore to create the delta connection

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

createDeltaConnection(): MockDeltaConnection;

Returns

Return type: MockDeltaConnection

dirty

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

dirty(): void;

finalizeIdRange

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

finalizeIdRange(range: IdCreationRange): void;

Parameters

ParameterTypeDescription
rangeIdCreationRange

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.

This API is provided for existing users, but is not recommended for new users.

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.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

flushSomeMessages(numMessages: number): void;

Parameters

ParameterTypeDescription
numMessagesnumber

maybeProcessIdAllocationMessage

If the message is an idAllocation message, it will finalize the id range and return true. Otherwise, it will return false.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected maybeProcessIdAllocationMessage(message: ISequencedDocumentMessage): boolean;

Parameters

ParameterTypeDescription
messageISequencedDocumentMessage

Returns

Return type: boolean

process

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

process(message: ISequencedDocumentMessage): void;

Parameters

ParameterTypeDescription
messageISequencedDocumentMessage

processInternal

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected processInternal(message: ISequencedDocumentMessage): [boolean, unknown];

Parameters

ParameterTypeDescription
messageISequencedDocumentMessage

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.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

rebase(): void;

resolveHandle

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

resolveHandle(handle: IFluidHandle): Promise<IResponse>;

Parameters

ParameterTypeDescription
handleIFluidHandle

Returns

Return type: Promise<IResponse>

reSubmitMessages

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected reSubmitMessages(messagesToResubmit: {
content: any;
localOpMetadata?: unknown;
}[]): void;

Parameters

ParameterTypeDescription
messagesToResubmit{ content: any; localOpMetadata?: unknown; }[]

rollback

Rolls back all pending messages.

This API is provided for existing users, but is not recommended for new users.

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

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

runWithManualFlush(act: () => void | Promise<void>): Promise<void>;

Parameters

ParameterTypeDescription
act() => void | Promise<void>

Returns

Return type: Promise<void>

submit

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

submit(messageContent: any, localOpMetadata?: unknown): number;

Parameters

ParameterModifiersTypeDescription
messageContentany
localOpMetadataoptionalunknown

Returns

Return type: number