"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
var __asyncValues = (this && this.__asyncValues) || function (o) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var m = o[Symbol.asyncIterator], i;
    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
const imodeljs_frontend_1 = require("@bentley/imodeljs-frontend");
const TestContext_1 = require("./setup/TestContext");
const expect = chai.expect;
describe("IModel Elements", () => {
    let iModel;
    let elements;
    before(async function () {
        const testContext = await TestContext_1.TestContext.instance();
        if (!testContext.settings.runiModelReadRpcTests)
            this.skip();
        iModel = await testContext.iModelWithChangesets.getConnection();
        elements = iModel.elements;
    });
    it("should get props", async () => {
        const elementIds = [elements.rootSubjectId];
        const elementProps = await elements.getProps(elementIds);
        expect(elementProps).to.exist.and.be.not.empty;
    });
    it("should query props", async () => {
        const elementProps = await elements.queryProps({ from: imodeljs_frontend_1.SpatialModelState.classFullName });
        expect(elementProps).to.exist.and.be.not.empty;
    });
    it("should query ids", async () => {
        const ids = await elements.queryIds({ limit: 10, from: "BisCore:Subject" });
        expect(ids).to.exist;
    });
});
describe("Operational: Execute Query", () => {
    it("should successfully execute a simple query", async function () {
        var e_1, _a;
        const testContext = await TestContext_1.TestContext.instance();
        if (!testContext.settings.runiModelReadRpcTests)
            this.skip();
        const iModel = await testContext.iModelWithChangesets.getConnection();
        const query = "select count(*) nRows from(SELECT ECInstanceId FROM Bis.Element LIMIT 50)";
        const rows = [];
        try {
            for (var _b = __asyncValues(iModel.query(query)), _c; _c = await _b.next(), !_c.done;) {
                const row = _c.value;
                rows.push(row);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
            }
            finally { if (e_1) throw e_1.error; }
        }
        expect(rows).to.be.not.empty;
    });
});
//# sourceMappingURL=Elements.test.js.map