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.
publicconstructor(persister?: JsonFilePersister)
- persister: JsonFilePersister
- (optional) persister component that loads and saves data from/to a flat file.
Fields
Instance methods
CreateAsync
creates and save objects into the _objects variable.
public virtualTask<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 virtualTask ClearAsync()
DeleteAsync
Removes an object from the _objects variable.
public virtualTask/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 virtualTask<DataPage<T>> GetAsync(IContext context, FilterParams filter, PagingParams paging)
- context: IContext - (optional) a context to trace execution through a call chain.
- filter: FilterParams - filter
- paging: PagingParams - paging parameters
- returns: Task<DataPage<T>> - Data page
GetAsync
Gets an object based on a given projection.
public virtualTask<DataPage<object>> GetAsync(IContext context, FilterParams filter, PagingParams paging, ProjectionParams projection)
- context: IContext - (optional) a context to trace execution through a call chain.
- filter: FilterParams - filter
- paging: PagingParams - paging parameters
- projection: ProjectionParams - projection parameters
- returns: Task<DataPage<object>> - data page
GetByIdAsync
Gets an object from the _objects variable based on a given id.
public virtualTask<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 virtualTask<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 virtualTask<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 virtualTask<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