Exemple #1
0
        public virtual void Dispose()
        {
            TelnyxConfiguration.SetApiBase(this.origApiBase);
            TelnyxConfiguration.SetApiKey(this.origApiKey);

            TelnyxMockHandler.StopTelnyxMock();
        }
Exemple #2
0
        public TelnyxMockFixture()
        {
            if (TelnyxMockHandler.StartTelnyxMock())
            {
                this.port = TelnyxMockHandler.Port.ToString();
            }
            else
            {
                this.port = Environment.GetEnvironmentVariable("TELNYX_MOCK_PORT") ?? "12111";
            }

            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                    .Build();

            this.telnyx_api_key = config["TelnyxApiKey"];
            if (string.IsNullOrEmpty(this.telnyx_api_key))
            {
                this.telnyx_api_key = Environment.GetEnvironmentVariable("TelnyxApiKey");
            }
            else
            {
                Environment.SetEnvironmentVariable("TelnyxApiKey", this.telnyx_api_key);
            }

            this.EnsureTelnyxMockMinimumVersion();

            this.origApiBase = TelnyxConfiguration.GetApiBase();
            this.origApiKey  = TelnyxConfiguration.GetApiKey();

            TelnyxConfiguration.SetApiBase($"http://localhost:{this.port}/v2");
            TelnyxConfiguration.SetApiKey(this.telnyx_api_key);
        }