@itwin/presentation-testing 3.5.0-dev.8 → 3.6.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -1
- package/lib/cjs/presentation-testing/Helpers.d.ts +4 -0
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +11 -1
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts +47 -0
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -0
- package/lib/cjs/presentation-testing/IModelUtilities.js +78 -0
- package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -0
- package/lib/cjs/presentation-testing.d.ts +4 -4
- package/lib/cjs/presentation-testing.d.ts.map +1 -1
- package/lib/cjs/presentation-testing.js +4 -4
- package/lib/cjs/presentation-testing.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts +4 -0
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +10 -0
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.d.ts +47 -0
- package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -0
- package/lib/esm/presentation-testing/IModelUtilities.js +70 -0
- package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -0
- package/lib/esm/presentation-testing.d.ts +4 -4
- package/lib/esm/presentation-testing.d.ts.map +1 -1
- package/lib/esm/presentation-testing.js +4 -4
- package/lib/esm/presentation-testing.js.map +1 -1
- package/package.json +13 -13
- package/lib/cjs/presentation-testing/IModelBuilder.d.ts +0 -46
- package/lib/cjs/presentation-testing/IModelBuilder.d.ts.map +0 -1
- package/lib/cjs/presentation-testing/IModelBuilder.js +0 -171
- package/lib/cjs/presentation-testing/IModelBuilder.js.map +0 -1
- package/lib/cjs/presentation-testing/IModelTestUtility.d.ts +0 -25
- package/lib/cjs/presentation-testing/IModelTestUtility.d.ts.map +0 -1
- package/lib/cjs/presentation-testing/IModelTestUtility.js +0 -63
- package/lib/cjs/presentation-testing/IModelTestUtility.js.map +0 -1
- package/lib/esm/presentation-testing/IModelBuilder.d.ts +0 -46
- package/lib/esm/presentation-testing/IModelBuilder.d.ts.map +0 -1
- package/lib/esm/presentation-testing/IModelBuilder.js +0 -147
- package/lib/esm/presentation-testing/IModelBuilder.js.map +0 -1
- package/lib/esm/presentation-testing/IModelTestUtility.d.ts +0 -25
- package/lib/esm/presentation-testing/IModelTestUtility.d.ts.map +0 -1
- package/lib/esm/presentation-testing/IModelTestUtility.js +0 -59
- package/lib/esm/presentation-testing/IModelTestUtility.js.map +0 -1
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module IModel
|
|
7
|
-
*/
|
|
8
|
-
import { Drawing, DrawingModel, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from "@itwin/core-backend";
|
|
9
|
-
import { Guid, Id64, ProcessDetector } from "@itwin/core-bentley";
|
|
10
|
-
import { Code, IModel, RelatedElement } from "@itwin/core-common";
|
|
11
|
-
import { assert } from "chai";
|
|
12
|
-
import { tmpdir } from "os";
|
|
13
|
-
import path, { join } from "path";
|
|
14
|
-
export class IModelBuilder {
|
|
15
|
-
/**
|
|
16
|
-
* Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
|
|
17
|
-
* @return [modeledElementId, modelId]
|
|
18
|
-
*/
|
|
19
|
-
static createAndInsertPhysicalPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
20
|
-
const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);
|
|
21
|
-
const modeledElementRef = new RelatedElement({ id: eid });
|
|
22
|
-
const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);
|
|
23
|
-
return [eid, mid];
|
|
24
|
-
}
|
|
25
|
-
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
26
|
-
static createAndInsertPhysicalPartition(testDb, newModelCode, parentId) {
|
|
27
|
-
const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;
|
|
28
|
-
const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);
|
|
29
|
-
const modeledElementProps = {
|
|
30
|
-
classFullName: PhysicalPartition.classFullName,
|
|
31
|
-
parent,
|
|
32
|
-
model,
|
|
33
|
-
code: newModelCode,
|
|
34
|
-
};
|
|
35
|
-
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
36
|
-
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
37
|
-
}
|
|
38
|
-
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
39
|
-
static createAndInsertPhysicalModel(testDb, modeledElementRef, privateModel = false) {
|
|
40
|
-
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });
|
|
41
|
-
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
42
|
-
assert.isTrue(Id64.isValidId64(newModelId));
|
|
43
|
-
assert.isTrue(Id64.isValidId64(newModel.id));
|
|
44
|
-
assert.deepEqual(newModelId, newModel.id);
|
|
45
|
-
return newModelId;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
|
|
49
|
-
* @return [modeledElementId, modelId]
|
|
50
|
-
*/
|
|
51
|
-
static createAndInsertDrawingPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
52
|
-
const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);
|
|
53
|
-
const modeledElementRef = new RelatedElement({ id: eid });
|
|
54
|
-
const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);
|
|
55
|
-
return [eid, mid];
|
|
56
|
-
}
|
|
57
|
-
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
58
|
-
static createAndInsertDrawingPartition(testDb, newModelCode, parentId) {
|
|
59
|
-
const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;
|
|
60
|
-
const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);
|
|
61
|
-
const modeledElementProps = {
|
|
62
|
-
classFullName: Drawing.classFullName,
|
|
63
|
-
parent,
|
|
64
|
-
model,
|
|
65
|
-
code: newModelCode,
|
|
66
|
-
};
|
|
67
|
-
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
68
|
-
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
69
|
-
}
|
|
70
|
-
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
71
|
-
static createAndInsertDrawingModel(testDb, modeledElementRef, privateModel = false) {
|
|
72
|
-
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });
|
|
73
|
-
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
74
|
-
assert.isTrue(Id64.isValidId64(newModelId));
|
|
75
|
-
assert.isTrue(Id64.isValidId64(newModel.id));
|
|
76
|
-
assert.deepEqual(newModelId, newModel.id);
|
|
77
|
-
return newModelId;
|
|
78
|
-
}
|
|
79
|
-
// Create a DrawingObject. (Does not insert it.)
|
|
80
|
-
static createDrawingGraphic(testImodel, modelId, categoryId, elemCode) {
|
|
81
|
-
const elementProps = {
|
|
82
|
-
classFullName: "BisCore:DrawingGraphic",
|
|
83
|
-
model: modelId,
|
|
84
|
-
category: categoryId,
|
|
85
|
-
code: elemCode ? elemCode : Code.createEmpty(),
|
|
86
|
-
};
|
|
87
|
-
return testImodel.elements.createElement(elementProps);
|
|
88
|
-
}
|
|
89
|
-
// Create a PhysicalObject. (Does not insert it.)
|
|
90
|
-
static createPhysicalObject(testImodel, modelId, categoryId, elemCode) {
|
|
91
|
-
const elementProps = {
|
|
92
|
-
classFullName: "Generic:PhysicalObject",
|
|
93
|
-
model: modelId,
|
|
94
|
-
category: categoryId,
|
|
95
|
-
code: elemCode ? elemCode : Code.createEmpty(),
|
|
96
|
-
};
|
|
97
|
-
return testImodel.elements.createElement(elementProps);
|
|
98
|
-
}
|
|
99
|
-
static getUniqueModelCode(testDb, newModelCodeBase) {
|
|
100
|
-
let newModelCode = newModelCodeBase;
|
|
101
|
-
let iter = 0;
|
|
102
|
-
while (true) {
|
|
103
|
-
const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);
|
|
104
|
-
if (testDb.elements.queryElementIdByCode(modelCode) === undefined)
|
|
105
|
-
return modelCode;
|
|
106
|
-
newModelCode = newModelCodeBase + iter;
|
|
107
|
-
++iter;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
|
|
111
|
-
static generateUniqueName(baseName) {
|
|
112
|
-
return `${baseName} - ${Guid.createValue()}`;
|
|
113
|
-
}
|
|
114
|
-
/** Prepare for an output file by:
|
|
115
|
-
* - Resolving the output file name under the known test output directory
|
|
116
|
-
* - Making directories as necessary
|
|
117
|
-
* - Removing a previous copy of the output file
|
|
118
|
-
* @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
|
|
119
|
-
* @param fileName Name of output fille
|
|
120
|
-
*/
|
|
121
|
-
static prepareOutputFile(subDirName, fileName) {
|
|
122
|
-
if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))
|
|
123
|
-
IModelJsFs.mkdirSync(KnownTestLocations.outputDir);
|
|
124
|
-
const outputDir = path.join(KnownTestLocations.outputDir, subDirName);
|
|
125
|
-
if (!IModelJsFs.existsSync(outputDir))
|
|
126
|
-
IModelJsFs.mkdirSync(outputDir);
|
|
127
|
-
const outputFile = path.join(outputDir, fileName);
|
|
128
|
-
if (IModelJsFs.existsSync(outputFile))
|
|
129
|
-
IModelJsFs.unlinkSync(outputFile);
|
|
130
|
-
return outputFile;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export class KnownTestLocations {
|
|
134
|
-
/** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
|
|
135
|
-
static get assetsDir() {
|
|
136
|
-
return join(__dirname, "assets");
|
|
137
|
-
}
|
|
138
|
-
/** The directory where tests can write. */
|
|
139
|
-
static get outputDir() {
|
|
140
|
-
if (ProcessDetector.isMobileAppBackend) {
|
|
141
|
-
return join(tmpdir(), "output");
|
|
142
|
-
}
|
|
143
|
-
// Assume that we are running in nodejs
|
|
144
|
-
return join(__dirname, "output");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=IModelBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IModelBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAqB,UAAU,EAAE,2BAA2B,EAAE,aAAa,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxL,OAAO,EAAE,IAAI,EAAE,IAAI,EAAc,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAoD,MAAM,EAAuC,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzJ,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO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ClE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC;YACtD,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAErD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC;YACnC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAElC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;YACnC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAEpC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAED,MAAM,OAAO,kBAAkB;IAE7B,6GAA6G;IACtG,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IACpC,MAAM,KAAK,SAAS;QACzB,IAAI,eAAe,CAAC,kBAAkB,EAAE;YACtC,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;SACjC;QAED,uCAAuC;QACvC,OAAO,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModel\r\n */\r\n\r\nimport { Drawing, DrawingModel, Element, IModelDb, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from \"@itwin/core-backend\";\r\nimport { Guid, Id64, Id64String, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { Code, CodeProps, ElementProps, GeometricElement2dProps, IModel, LocalFileName, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { assert } from \"chai\";\r\nimport { tmpdir } from \"os\";\r\nimport path, { join } from \"path\";\r\n\r\nexport class IModelBuilder {\r\n /**\r\n * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: PhysicalPartition.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n /**\r\n * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: Drawing.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n // Create a DrawingObject. (Does not insert it.)\r\n public static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: GeometricElement2dProps = {\r\n classFullName: \"BisCore:DrawingGraphic\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n // Create a PhysicalObject. (Does not insert it.)\r\n public static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: PhysicalElementProps = {\r\n classFullName: \"Generic:PhysicalObject\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n public static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code {\r\n let newModelCode: string = newModelCodeBase;\r\n let iter: number = 0;\r\n while (true) {\r\n const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);\r\n if (testDb.elements.queryElementIdByCode(modelCode) === undefined)\r\n return modelCode;\r\n\r\n newModelCode = newModelCodeBase + iter;\r\n ++iter;\r\n }\r\n }\r\n\r\n /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */\r\n public static generateUniqueName(baseName: string) {\r\n return `${baseName} - ${Guid.createValue()}`;\r\n }\r\n\r\n /** Prepare for an output file by:\r\n * - Resolving the output file name under the known test output directory\r\n * - Making directories as necessary\r\n * - Removing a previous copy of the output file\r\n * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.\r\n * @param fileName Name of output fille\r\n */\r\n public static prepareOutputFile(subDirName: string, fileName: string): LocalFileName {\r\n if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))\r\n IModelJsFs.mkdirSync(KnownTestLocations.outputDir);\r\n\r\n const outputDir = path.join(KnownTestLocations.outputDir, subDirName);\r\n if (!IModelJsFs.existsSync(outputDir))\r\n IModelJsFs.mkdirSync(outputDir);\r\n\r\n const outputFile = path.join(outputDir, fileName);\r\n if (IModelJsFs.existsSync(outputFile))\r\n IModelJsFs.unlinkSync(outputFile);\r\n\r\n return outputFile;\r\n }\r\n}\r\n\r\nexport class KnownTestLocations {\r\n\r\n /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */\r\n public static get assetsDir(): string {\r\n return join(__dirname, \"assets\");\r\n }\r\n\r\n /** The directory where tests can write. */\r\n public static get outputDir(): string {\r\n if (ProcessDetector.isMobileAppBackend) {\r\n return join(tmpdir(), \"output\");\r\n }\r\n\r\n // Assume that we are running in nodejs\r\n return join(__dirname, \"output\");\r\n }\r\n}\r\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { GuidString } from "@itwin/core-bentley";
|
|
2
|
-
import { Code, ElementProps } from "@itwin/core-common";
|
|
3
|
-
/**
|
|
4
|
-
* Test utility to push an iModel.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare class IModelTestUtility {
|
|
9
|
-
iTwinId: GuidString;
|
|
10
|
-
iModelId: string;
|
|
11
|
-
outputFile: string;
|
|
12
|
-
private _iModel;
|
|
13
|
-
private _modelId;
|
|
14
|
-
createIModel(): void;
|
|
15
|
-
addPhysicalModel(): string;
|
|
16
|
-
addDrawingModel(): string;
|
|
17
|
-
addSpatialCategory(elementProps: ElementProps): string;
|
|
18
|
-
addDrawingCategory(elementProps: ElementProps): string;
|
|
19
|
-
addPhysicalObject(categoryId: string): void;
|
|
20
|
-
addDrawingGraphic(categoryId: string): void;
|
|
21
|
-
getSpatialCategoryCode(codeValue: string): Code;
|
|
22
|
-
getDrawingCategoryCode(codeValue: string): Code;
|
|
23
|
-
closeIModel(): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=IModelTestUtility.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTestUtility.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;GAIG;AACH,qBAAa,iBAAiB;IACrB,OAAO,EAAG,UAAU,CAAC;IACrB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,QAAQ,CAAU;IAEnB,YAAY,IAAI,IAAI;IAMpB,gBAAgB,IAAI,MAAM;IAM1B,eAAe,IAAI,MAAM;IAMzB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,WAAW,IAAI,IAAI;CAG3B"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module TestUtilities
|
|
7
|
-
*/
|
|
8
|
-
import { DrawingCategory, SnapshotDb, SpatialCategory } from "@itwin/core-backend";
|
|
9
|
-
import { IModelBuilder } from "./IModelBuilder";
|
|
10
|
-
/**
|
|
11
|
-
* Test utility to push an iModel.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export class IModelTestUtility {
|
|
16
|
-
createIModel() {
|
|
17
|
-
this.outputFile = IModelBuilder.prepareOutputFile("IModelTest", IModelBuilder.generateUniqueName("IModelTest.bim"));
|
|
18
|
-
this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: "IModelTest" } });
|
|
19
|
-
this.iModelId = this._iModel.iModelId;
|
|
20
|
-
}
|
|
21
|
-
addPhysicalModel() {
|
|
22
|
-
[, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, "TestPhysicalModel"), false);
|
|
23
|
-
this._iModel.saveChanges("Added test model");
|
|
24
|
-
return this._modelId;
|
|
25
|
-
}
|
|
26
|
-
addDrawingModel() {
|
|
27
|
-
[, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, "TestDrawingModel"), false);
|
|
28
|
-
this._iModel.saveChanges("Added test model");
|
|
29
|
-
return this._modelId;
|
|
30
|
-
}
|
|
31
|
-
addSpatialCategory(elementProps) {
|
|
32
|
-
const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());
|
|
33
|
-
this._iModel.saveChanges("Added spatial category");
|
|
34
|
-
return categoryId;
|
|
35
|
-
}
|
|
36
|
-
addDrawingCategory(elementProps) {
|
|
37
|
-
const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());
|
|
38
|
-
this._iModel.saveChanges("Added drawing category");
|
|
39
|
-
return categoryId;
|
|
40
|
-
}
|
|
41
|
-
addPhysicalObject(categoryId) {
|
|
42
|
-
this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());
|
|
43
|
-
this._iModel.saveChanges("Added physical object");
|
|
44
|
-
}
|
|
45
|
-
addDrawingGraphic(categoryId) {
|
|
46
|
-
this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());
|
|
47
|
-
this._iModel.saveChanges("Added drawing graphic");
|
|
48
|
-
}
|
|
49
|
-
getSpatialCategoryCode(codeValue) {
|
|
50
|
-
return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
51
|
-
}
|
|
52
|
-
getDrawingCategoryCode(codeValue) {
|
|
53
|
-
return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
54
|
-
}
|
|
55
|
-
closeIModel() {
|
|
56
|
-
this._iModel.close();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=IModelTestUtility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTestUtility.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,eAAe,EAAY,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAOrB,YAAY;QACjB,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,EAAE,aAAa,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACpH,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACxC,CAAC;IAEM,gBAAgB;QACrB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,wCAAwC,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,KAAK,CAAC,CAAC;QACrK,IAAI,CAAC,OAAO,CAAC,WAA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CAAC;IAEM,iBAAiB,CAAC,UAAkB;QACzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module TestUtilities\r\n */\r\nimport { DrawingCategory, IModelDb, SnapshotDb, SpatialCategory } from \"@itwin/core-backend\";\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { Code, ElementProps } from \"@itwin/core-common\";\r\nimport { IModelBuilder } from \"./IModelBuilder\";\r\n\r\n/**\r\n * Test utility to push an iModel.\r\n *\r\n * @internal\r\n */\r\nexport class IModelTestUtility {\r\n public iTwinId!: GuidString;\r\n public iModelId!: string;\r\n public outputFile!: string;\r\n private _iModel!: IModelDb;\r\n private _modelId!: string;\r\n\r\n public createIModel(): void {\r\n this.outputFile = IModelBuilder.prepareOutputFile(\"IModelTest\", IModelBuilder.generateUniqueName(\"IModelTest.bim\"));\r\n this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: \"IModelTest\" } });\r\n this.iModelId = this._iModel.iModelId;\r\n }\r\n\r\n public addPhysicalModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestPhysicalModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addDrawingModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestDrawingModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addSpatialCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added spatial category\");\r\n return categoryId;\r\n }\r\n\r\n public addDrawingCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added drawing category\");\r\n return categoryId;\r\n }\r\n\r\n public addPhysicalObject(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added physical object\");\r\n }\r\n\r\n public addDrawingGraphic(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added drawing graphic\");\r\n }\r\n\r\n public getSpatialCategoryCode(codeValue: string): Code {\r\n return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public getDrawingCategoryCode(codeValue: string): Code {\r\n return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public closeIModel(): void {\r\n this._iModel.close();\r\n }\r\n}\r\n"]}
|