protected void TelemetryInitializerUninstall(string sourceDocument)
{
string resourceName = "Microsoft.ApplicationInsights.Resources.ApplicationInsights.config.install.xdt";
string intermediaryDocument;
Assembly assembly = typeof(ModuleTransformTests).Assembly;
Stream stream = 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);
intermediaryDocument = targetDocument.OuterXml;
}
resourceName = "Microsoft.ApplicationInsights.Resources.ApplicationInsights.config.uninstall.xdt";
stream = 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(intermediaryDocument);
transformation.Apply(targetDocument);
string uninstalledDocument = targetDocument.OuterXml;
XElement cleanDocument = XElement.Parse(sourceDocument);
XElement dirtyDocument = XElement.Parse(uninstalledDocument);
Assert.True(XNode.DeepEquals(cleanDocument, dirtyDocument));
}
}