Last active
August 29, 2015 14:23
-
-
Save BryanWilhite/c6126bfd6e37b676981f to your computer and use it in GitHub Desktop.
ShouldTransformWebConfig() uses WebConfigTransformRunner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Test context extensions: should transform web configuration. | |
/// </summary> | |
/// <param name="context">The context.</param> | |
/// <param name="pathToWebConfigTransformRunnerExe">The path to web configuration transform runner executable.</param> | |
/// <param name="outputFile">The output file.</param> | |
/// <param name="transformFile">The transform file.</param> | |
/// <param name="webConfigFile">The web configuration file.</param> | |
/// <param name="workingDirectory">The working directory.</param> | |
/// <param name="xPaths">The x paths.</param> | |
public static void ShouldTransformWebConfig(this TestContext context, string pathToWebConfigTransformRunnerExe, | |
string outputFile, string transformFile, string webConfigFile, string workingDirectory, IEnumerable<string> xPaths) | |
{ | |
context.WriteLine("Transforming {0} with {1} in {2}...", | |
Path.GetFileName(transformFile), | |
Path.GetFileName(webConfigFile), | |
workingDirectory); | |
var arguments = string.Format("{0} {1} {2}", webConfigFile, transformFile, outputFile); | |
var startInfo = context.GetDefaultProcessStartInfo(arguments, pathToWebConfigTransformRunnerExe, workingDirectory); | |
context.StartProcessAndWaitForExit(startInfo); | |
Assert.IsTrue(File.Exists(outputFile), "The expected output file is not here."); | |
var xd = XDocument.Load(outputFile); | |
xPaths.ForEachInEnumerable(i => | |
{ | |
context.WriteLine("Finding node at {0}...", i); | |
var e = XObjectUtility.GetXNode(xd.Root, i); | |
Assert.IsNotNull(e, "The expected Configuration node is not here."); | |
context.WriteLine("Found node {0}.", e.GetOuterXml()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment