in src/LibraryTest/Library/ConfigurationTests.cs [63:106]
public void ConfigurationTests_EnvironmentVariablesAreResolved()
{
// ARRANGE
var config = $@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Configuration>
<Host>%Input_Host%</Host>
<Port>%Input_Port%</Port>
<InstrumentationKey>%ConfigTestInstrumentationKey%</InstrumentationKey>
<LiveMetricsStreamAuthenticationApiKey></LiveMetricsStreamAuthenticationApiKey>
<AdaptiveSampling Enabled=""true"">
<MaxEventsPerSecond>%ISTIO_MIXER_PLUGIN_AI_ADAPTIVE_SAMPLING_EVENTS_LIMIT%</MaxEventsPerSecond>
<!--Telemetry items other than events are counted together-->
<MaxOtherItemsPerSecond>%ISTIO_MIXER_PLUGIN_AI_ADAPTIVE_SAMPLING_LIMIT%</MaxOtherItemsPerSecond>
</AdaptiveSampling>
<Endpoints>
<TelemetryChannelEndpoint>%TelemetryChannelEndpoint%</TelemetryChannelEndpoint>
<QuickPulseServiceEndpoint>%QuickPulseEndpoint%</QuickPulseServiceEndpoint>
</Endpoints>
</Configuration>
";
var rand = new Random();
string host = Guid.NewGuid().ToString();
string port = rand.Next().ToString();
string ikey = Guid.NewGuid().ToString();
string telemetryChannelEndpoint = Guid.NewGuid().ToString();
string quickPulseEndpoint = Guid.NewGuid().ToString();
Environment.SetEnvironmentVariable("Input_Host", host);
Environment.SetEnvironmentVariable("Input_Port", port);
Environment.SetEnvironmentVariable("ConfigTestInstrumentationKey", ikey);
Environment.SetEnvironmentVariable("TelemetryChannelEndpoint", telemetryChannelEndpoint);
Environment.SetEnvironmentVariable("QuickPulseEndpoint", quickPulseEndpoint);
// ACT
var configuration = new Configuration(config);
// ASSERT
Assert.AreEqual(host, configuration.Host);
Assert.AreEqual(port, configuration.Port.ToString());
Assert.AreEqual(ikey, configuration.InstrumentationKey);
Assert.AreEqual(telemetryChannelEndpoint, configuration.Endpoints_TelemetryChannelEndpoint);
Assert.AreEqual(quickPulseEndpoint, configuration.Endpoints_QuickPulseServiceEndpoint);
}