コード例 #1
0
        /// <summary>
        /// Create commands to restore any pre-existing published assemblies
        /// </summary>
        /// <param name="sessionInfo">The session info.</param>
        /// <returns></returns>
        private static List <ICommand> CreateRestoreInstrumentedAssembliesCommands(SessionInfo sessionInfo)
        {
            List <ICommand> commands = new List <ICommand>();

            foreach (AssemblyUnderTestConfig assemblyUnderTest in sessionInfo.Configuration.AssembliesUnderTestConfig)
            {
                RestoreAssemblyCommand restoreAssemblyCommand = new RestoreAssemblyCommand(Path.GetFileName(assemblyUnderTest.AssemblyPath), sessionInfo.AssemblyBackupDirectory, true);
                restoreAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                commands.Add(restoreAssemblyCommand);

                if (assemblyUnderTest.IsStrongNamed)
                {
                    SnCommand snCommand = new SnCommand(string.Format("-Vu \"{0}\"", assemblyUnderTest.AssemblyPath), true);
                    snCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                    commands.Add(snCommand);
                }
            }

            // Restore the test assemblies
            foreach (TestAssemblyConfig testAssemblyConfig in sessionInfo.Configuration.TestAssembliesConfig)
            {
                RestoreAssemblyCommand restoreAssemblyCommand = new RestoreAssemblyCommand(Path.GetFileName(testAssemblyConfig.AssemblyPath), sessionInfo.AssemblyBackupDirectory, true);
                restoreAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                commands.Add(restoreAssemblyCommand);
            }

            foreach (ReferencedAssemblyConfig referencedAssemblyConfig in sessionInfo.Configuration.ReferencedAssembliesConfig)
            {
                RestoreAssemblyCommand restoreAssemblyCommand = new RestoreAssemblyCommand(Path.GetFileName(referencedAssemblyConfig.AssemblyPath), sessionInfo.AssemblyBackupDirectory, true);
                restoreAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                commands.Add(restoreAssemblyCommand);
            }

            return(commands);
        }
コード例 #2
0
        /// <summary>
        /// Create commands to publish the instrumented assemblies.
        /// </summary>
        /// <param name="sessionInfo">The session info.</param>
        /// <returns></returns>
        private static List <ICommand> CreatePublishInstrumentedAssembliesCommands(SessionInfo sessionInfo)
        {
            List <ICommand> commands = new List <ICommand>();

            // Publish the code coverage assemblies
            foreach (AssemblyUnderTestConfig assemblyUnderTest in sessionInfo.Configuration.AssembliesUnderTestConfig)
            {
                string assemblyPath = Path.Combine(sessionInfo.AssembliesDirectory, Path.GetFileName(assemblyUnderTest.AssemblyPath));

                if (assemblyUnderTest.IsStrongNamed)
                {
                    SnCommand snCommand = new SnCommand(string.Format("-Vr \"{0}\"", assemblyUnderTest.AssemblyPath), false);
                    snCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                    commands.Add(snCommand);
                }

                PublishAssemblyCommand publishAssemblyCommand = new PublishAssemblyCommand(assemblyPath, assemblyUnderTest.PublishPath, sessionInfo.AssemblyBackupDirectory, false);
                publishAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                commands.Add(publishAssemblyCommand);
            }

            // Publish the test assemblies
            foreach (TestAssemblyConfig testAssemblyConfig in sessionInfo.Configuration.TestAssembliesConfig)
            {
                if (!string.IsNullOrEmpty(testAssemblyConfig.PublishPath))
                {
                    PublishAssemblyCommand publishAssemblyCommand = new PublishAssemblyCommand(testAssemblyConfig.AssemblyPath, testAssemblyConfig.PublishPath, sessionInfo.AssemblyBackupDirectory, false);
                    publishAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                    commands.Add(publishAssemblyCommand);
                }
            }

            // Publish the referenced assemblies
            foreach (ReferencedAssemblyConfig referenecedAssemblyConfig in sessionInfo.Configuration.ReferencedAssembliesConfig)
            {
                PublishAssemblyCommand publishAssemblyCommand = new PublishAssemblyCommand(referenecedAssemblyConfig.AssemblyPath, referenecedAssemblyConfig.PublishPath, sessionInfo.AssemblyBackupDirectory, false);
                publishAssemblyCommand.OutputDataReceived += new EventHandler <OutputDataEventArgs>(WriteCommandOutputToConsole);
                commands.Add(publishAssemblyCommand);
            }

            return(commands);
        }