AbstractMockDbPersistence<T>

Abstract Mock DB Persistence (keep data in memory) with ability to test basic projections

Description

The AbstractMockDbPersistence class allows you to keep data in memory with the ability to test basic projections.

Important points The class that contains “Id” property (with no dependencies to IIdentifiable).

Constructors

Creates a new instance of the file persistence component.

public constructor(persister?: JsonFilePersister)

  • persister: JsonFilePersister - (optional) persister component that loads and saves data from/to a flat file.

Fields

MaxPageSize

Maximum page size

protected MaxPageSize: int = 100

_objects

Objects

protected _objects: Dictionary<string, T>

Instance methods

CreateAsync

creates and save objects into the _objects variable.

public virtual Task<T> CreateAsync(IContext context, T @object)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • @object: T - object

ClearAsync

Clears the _objects variable.

public virtual Task ClearAsync()

DeleteAsync

Removes an object from the _objects variable.

public virtual Task/ DeleteAsync(IContext correlantexttionId, string id)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • id: string - id

GetAsync

Gets an object from the _objects variable.

public virtual Task<DataPage<T>> GetAsync(IContext context, FilterParams filter, PagingParams paging)

GetAsync

Gets an object based on a given projection.

public virtual Task<DataPage<object>> GetAsync(IContext context, FilterParams filter, PagingParams paging, ProjectionParams projection)

GetByIdAsync

Gets an object from the _objects variable based on a given id.

public virtual Task<T> GetByIdAsync(IContext context, string id)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • id: string - id

Gets an object based on a given id and projection.

public virtual Task<object> GetByIdAsync(IContext context, string id, ProjectionParams projection)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • id: string - id
  • projection: ProjectionParams - projection parameters

UpdateAsync

Updates an object stored in _objects.

public virtual Task<T> UpdateAsync(IContext context, T @object)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • @object: T - object to update

ModifyAsync

Modifies a value of the field of an object.

public virtual Task<T> ModifyAsync(IContext context, string id, AnyValueMap updateMap)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • id: string - id
  • updateMap: AnyValueMap - update map