"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module RpcInterface
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestRpcManager = void 0;
const RpcConfiguration_1 = require("./core/RpcConfiguration");
/** An RpcManager that uses RpcDefaultConfiguration/RpcDirectProtocol to make client stubs invoke
 * registered server impls as direct method calls within the same JavaScript context. In other words,
 * TestRpcManager sets up a protocol that uses our remoting mechanism but cuts out the communication
 * part of it. (No IPC or XHR is used or required.)
 * Nevertheless, all of the rest of the call marshalling and operation monitoring mechanism is used.
 * That makes TestRpcManager a way to write simple, single-process integration tests for frontends
 * and backends that actually use RpcInterfaces. Note that to write such a single-process integration
 * test, you must make *both* client and server use TestRpcManager to configure their RpcInterfaces.
 * It will not work if one side uses TestRpcManager and the other uses some other protocol (say, cloud).
 * That means that you must actually program the backend to know when it is running in direct test
 * mode and to employ TestRpcManager in that case.
 * @internal
 */
class TestRpcManager {
    static initialize(interfaces) {
        const config = class extends RpcConfiguration_1.RpcDefaultConfiguration {
            interfaces = () => interfaces;
        };
        for (const def of interfaces)
            RpcConfiguration_1.RpcConfiguration.assign(def, () => RpcConfiguration_1.RpcDefaultConfiguration);
        const instance = RpcConfiguration_1.RpcConfiguration.obtain(config);
        RpcConfiguration_1.RpcConfiguration.initializeInterfaces(instance);
    }
}
exports.TestRpcManager = TestRpcManager;
//# sourceMappingURL=TestRpcManager.js.map