Beispiel #1
0
        /// <summary>
        /// Executes the specified command. Assume working directory is TestFiles\MsiInput\ dir.
        /// </summary>
        /// <param name="commandLineArguments">The command line arguments (everything after the exe name).</param>
        /// <param name="testName">The name of hte test (used to formulate the expectedEntries output dir).</param>
        /// <param name="actualEntriesOutputDir">The output directory where the actual extraction is expected to occur.</param>
        private void TestExtraction(string commandLineArguments, string testName, string actualEntriesOutputDir, bool useInProcessForDebugging)
        {
            string consoleOutput;
            var    actualOutDir = new DirectoryInfo(actualEntriesOutputDir);

            if (actualOutDir.Exists)
            {
                DeleteDirectoryRecursive(actualOutDir);
            }
            int exitCode;

            if (useInProcessForDebugging)
            {
                exitCode = base.RunCommandLineInProccess(commandLineArguments);
            }
            else
            {
                exitCode = base.RunCommandLine(commandLineArguments, out consoleOutput);
            }

            var actualEntries     = FileEntryGraph.GetActualEntries(actualEntriesOutputDir, "Actual Entries");
            var actualEntriesFile = GetActualOutputFile(testName);

            actualEntries.Save(actualEntriesFile);
            Console.WriteLine("Actual entries saved to " + actualEntriesFile.FullName);
            var expectedEntries = GetExpectedEntriesForMsi(testName);

            AssertAreEqual(expectedEntries, actualEntries);
        }
Beispiel #2
0
        /// <summary>
        /// Extracts some or all of the files from the specified MSI and returns a <see cref="FileEntryGraph"/> representing the files that were extracted.
        /// </summary>
        /// <param name="msiFileName">The msi file to extract or null to extract all files.</param>
        /// <param name="fileNamesToExtractOrNull">The files to extract from the MSI or null to extract all files.</param>
        /// <param name="outputDir">A relative directory to extract output to or an empty string to use the default output directory.</param>
        /// <param name="skipReturningFileEntryGraph">True to return the <see cref="FileEntryGraph"/>. Otherwise null will be returned.</param>
        protected FileEntryGraph ExtractFilesFromMsi(string msiFileName, string[] fileNamesToExtractOrNull, Path outputDir, bool returnFileEntryGraph)
        {
            outputDir = GetTestOutputDir(outputDir, msiFileName);

            if (FileSystem.Exists(outputDir))
            {
                FileSystem.RemoveDirectory(outputDir, true);
            }
            Debug.Assert(!FileSystem.Exists(outputDir), "Directory still exists!");
            FileSystem.CreateDirectory(outputDir);

            //ExtractViaCommandLine(outputDir, msiFileName);
            ExtractInProcess(msiFileName, outputDir.PathString, fileNamesToExtractOrNull);
            if (returnFileEntryGraph)
            {
                //  build actual file entries extracted
                var actualEntries = FileEntryGraph.GetActualEntries(outputDir.PathString, msiFileName);
                // dump to actual dir (for debugging and updating tests)
                actualEntries.Save(GetActualOutputFile(msiFileName));
                return(actualEntries);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Executes the specified command. Assume working directory is TestFiles\MsiInput\ dir.
        /// </summary>
        /// <param name="commandLineArguments">The command line arguments (everything after the exe name).</param>
        /// <param name="testName">The name of hte test (used to formulate the expectedEntries output dir).</param>
        /// <param name="actualEntriesOutputDir">The output directory where the actual extraction is expected to occur.</param>
        private void TestExtraction(string commandLineArguments, string testName, string actualEntriesOutputDir, bool useInProcessForDebugging)
        {
            string consoleOutput;
            var    actualOutDir = new LessIO.Path(actualEntriesOutputDir).FullPath;

            if (actualOutDir.Exists)
            {
                FileSystem.RemoveDirectory(actualOutDir, true);
            }
            int exitCode;

            if (useInProcessForDebugging)
            {
                exitCode = base.RunCommandLineInProccess(commandLineArguments);
            }
            else
            {
                exitCode = base.RunCommandLine(commandLineArguments, out consoleOutput);
            }
            Assert.Equal(0, exitCode);
            var actualEntries     = FileEntryGraph.GetActualEntries(actualOutDir.FullPathString, "Actual Entries");
            var actualEntriesFile = GetActualOutputFile(testName);

            actualEntries.Save(actualEntriesFile);
            //Console.WriteLine("Actual entries saved to " + actualEntriesFile.FullName);
            var expectedEntries = GetExpectedEntriesForMsi(testName);

            AssertAreEqual(expectedEntries, actualEntries);
        }
Beispiel #4
0
        /// <summary>
        /// Extracts some or all of the files from the specified MSI and returns a <see cref="FileEntryGraph"/> representing the files that were extracted.
        /// </summary>
        /// <param name="msiFileName">The msi file to extract or null to extract all files.</param>
        protected FileEntryGraph ExtractFilesFromMsi(string msiFileName, string[] fileNamesToExtractOrNull)
        {
            //  build command line
            string outputDir = Path.Combine(AppPath, "MsiOutputTemp");

            outputDir = Path.Combine(outputDir, "_" + msiFileName);
            if (Directory.Exists(outputDir))
            {
                DeleteDirectoryRecursive(new DirectoryInfo(outputDir));
                Directory.Delete(outputDir, true);
            }
            Directory.CreateDirectory(outputDir);

            //ExtractViaCommandLine(outputDir, msiFileName);
            ExtractInProcess(msiFileName, outputDir, fileNamesToExtractOrNull);

            //  build actual file entries extracted
            var actualEntries = FileEntryGraph.GetActualEntries(outputDir, msiFileName);

            // dump to actual dir (for debugging and updating tests)
            actualEntries.Save(GetActualOutputFile(msiFileName));
            return(actualEntries);
        }