@itwin/presentation-testing
Version:
Testing utilities for iTwin.js Presentation library
75 lines • 3.59 kB
TypeScript
/** @packageDocumentation
* @module IModel
*/
import { IModelDb } from "@itwin/core-backend";
import { Id64String } from "@itwin/core-bentley";
import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
import { IModelConnection } from "@itwin/core-frontend";
/**
* Interface for IModel builder pattern. Used for building IModels to test rulesets.
* @beta
*/
export interface TestIModelBuilder {
/** Insert a model into the builder's iModel */
insertModel<TProps extends ModelProps>(props: TProps): Id64String;
/** Insert an element into the builder's iModel */
insertElement<TProps extends ElementProps>(props: TProps): Id64String;
/** Insert an element aspect into the specified element */
insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
/**
* Insert a relationship between two instances. The relationship is expected to be a subclass
* of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.
*/
insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
/**
* Create code for specified element.
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
*/
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
/**
* Import an ECSchema in a form of XML string into the builder's iModel.
*/
importSchema(schemaXml: string): Promise<void>;
}
/**
* Function that creates an iModel and returns a connection to it.
* @param name Name of test IModel
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
* @beta
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
*/
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
/**
* Function that creates an iModel and returns a connection to it.
* @param name Name of test IModel
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
* @beta
*/
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
/**
* Function that creates an iModel and returns a connection to it.
* @param mochaContext Mocha context to generate iModel name from
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
* @beta
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
*/
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
/**
* Function that creates an iModel and returns a connection to it.
* @param mochaContext Mocha context to generate iModel name from
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
* @beta
*/
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
/**
* Implementation of `IModelConnection` that allows opening local files in tests.
* @beta
*/
export declare class TestIModelConnection extends IModelConnection {
private readonly _db;
constructor(_db: IModelDb);
get isClosed(): boolean;
close(): Promise<void>;
static openFile(filePath: string): IModelConnection;
}
//# sourceMappingURL=IModelUtilities.d.ts.map