protected void TelemetryInitializerInstall(string sourceDocument, params string[] telemetryInitializerTypes)
{
string resourceName = "Microsoft.ApplicationInsights.Resources.ApplicationInsights.config.install.xdt";
Stream stream = typeof(ModuleTransformTests).Assembly.GetManifestResourceStream(resourceName);
using (StreamReader reader = new StreamReader(stream))
{
string transform = reader.ReadToEnd();
XmlTransformation transformation = new XmlTransformation(transform, false, null);
XmlDocument targetDocument = new XmlDocument();
targetDocument.LoadXml(sourceDocument);
transformation.Apply(targetDocument);
XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
manager.AddNamespace("ai", AppInsightsNamespace);
int moduleIndex = 0;
foreach (XPathNavigator module in targetDocument.CreateNavigator().Select("/ai:ApplicationInsights/ai:TelemetryInitializers/ai:Add/@Type", manager))
{
string contextInitializerType = telemetryInitializerTypes[moduleIndex++];
Assert.Equal(module.Value, contextInitializerType);
}
Assert.Equal(moduleIndex, telemetryInitializerTypes.Length);
}
}