public void Constructor_WhenLoggerIsNull_Throws()
        {
            var debuggerSetup = new DebuggerSetup();
            var visualStudio = MockRepository.GenerateStub<IVisualStudio>();

            Assert.Throws<ArgumentNullException>(() => new VisualStudioDebugger(debuggerSetup, null, visualStudio));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a copy of the options.
        /// </summary>
        /// <returns>The copy.</returns>
        public DebuggerSetup Copy()
        {
            var copy = new DebuggerSetup();

            copy.properties.AddAll(properties);
            return(copy);
        }
        public void DetachFromProcess_WhenProcessIsNull_Throws()
        {
            var debuggerSetup = new DebuggerSetup();
            var logger = MockRepository.GenerateStub<ILogger>();
            var debugger = new VisualStudioDebugger(debuggerSetup, logger, null);

            Assert.Throws<ArgumentNullException>(() => debugger.DetachFromProcess(null));
        }
        /// <inheritdoc/>
        protected override IProcess StartProcess(DebuggerSetup debuggerSetup)
        {
            if (process != null)
                throw new InvalidOperationException("Process already started.");

            process = StartProcessWithDebugger(debuggerSetup) ?? processCreator.Start(startInfo);
            return process;
        }
        private IProcess StartProcessWithDebugger(DebuggerSetup debuggerSetup)
        {
            if (debuggerSetup == null)
                return null;

            var debugger = debuggerManager.GetDebugger(debuggerSetup, Logger);
            var actual = debugger.LaunchProcess(startInfo);
            return new ProcessWrapper(actual);
        }
        /// <summary>
        /// Creates a Visual Studio debugger wrapper.
        /// </summary>
        /// <param name="debuggerSetup">The debugger setup options.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="visualStudio">The instance of Visual Studio, or null if it should automatically find or
        /// launch instances of Visual Studio as required.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="debuggerSetup"/>
        /// or <paramref name="logger"/> is null.</exception>
        public VisualStudioDebugger(DebuggerSetup debuggerSetup, ILogger logger, IVisualStudio visualStudio)
        {
            if (debuggerSetup == null)
                throw new ArgumentNullException("debuggerSetup");
            if (logger == null)
                throw new ArgumentNullException("logger");

            this.debuggerSetup = debuggerSetup;
            this.logger = logger;
            this.visualStudio = visualStudio;
        }
        /// <inheritdoc />
        public IDebugger GetDebugger(DebuggerSetup debuggerSetup, ILogger logger)
        {
            if (debuggerSetup == null)
                throw new ArgumentNullException("debuggerSetup");
            if (logger == null)
                throw new ArgumentNullException("logger");

            // FIXME: Should resolve service using IoC but we would have to start the runtime
            //        which is a lot of overhead for the host process.  -- Jeff.
            Type debuggerType = Type.GetType(VisualStudioDebuggerTypeName);
            if (debuggerType == null)
                return new NullDebugger();

            return (IDebugger)Activator.CreateInstance(debuggerType, debuggerSetup, logger, null);
        }
        /// <inheritdoc />
        public IDebugger GetDebugger(DebuggerSetup debuggerSetup, ILogger logger)
        {
            if (debuggerSetup == null)
            {
                throw new ArgumentNullException("debuggerSetup");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            // FIXME: Should resolve service using IoC but we would have to start the runtime
            //        which is a lot of overhead for the host process.  -- Jeff.
            Type debuggerType = Type.GetType(VisualStudioDebuggerTypeName);

            if (debuggerType == null)
            {
                return(new NullDebugger());
            }

            return((IDebugger)Activator.CreateInstance(debuggerType, debuggerSetup, logger, null));
        }
Beispiel #9
0
 /// <summary>
 /// Resets <see cref="DebuggerSetup"/> to its default value and sets <see cref="IsDebuggerSetupSpecified" /> to false.
 /// </summary>
 public void ResetDebuggerSetup()
 {
     debuggerSetup = null;
     isDebuggerSetupSpecified = false;
 }
Beispiel #10
0
        /// <summary>
        /// Merges the specified package to the current one.
        /// </summary>
        /// <param name="other">The other package to be merged.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="other"/> is null.</exception>
        public void MergeWith(TestPackage other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            if (other.isTestFrameworkOptionsSpecified)
            {
                isTestFrameworkOptionsSpecified = true;
                testFrameworkOptions.Properties.MergeWith(other.TestFrameworkOptions.Properties);
            }

            if (other.isTestFrameworkFallbackModeSpecified && !isTestFrameworkFallbackModeSpecified)
            {
                isTestFrameworkFallbackModeSpecified = true;
                testFrameworkFallbackMode = other.testFrameworkFallbackMode;
            }

            if (other.isShadowCopySpecified && !isShadowCopySpecified)
            {
                isShadowCopySpecified = true;
                shadowCopy |= other.shadowCopy;
            }

            if (other.isDebuggerSetupSpecified)
            {
                isDebuggerSetupSpecified = true;

                if (other.debuggerSetup != null)
                {
                    if (debuggerSetup == null)
                        debuggerSetup = new DebuggerSetup();

                    debuggerSetup.Properties.MergeWith(other.debuggerSetup.Properties);
                }
            }

            if (other.isApplicationBaseDirectorySpecified && !isApplicationBaseDirectorySpecified)
            {
                isApplicationBaseDirectorySpecified = true;
                applicationBaseDirectory = other.applicationBaseDirectory;
            }

            if (other.isWorkingDirectorySpecified && !isWorkingDirectorySpecified)
            {
                isWorkingDirectorySpecified = true;
                workingDirectory = other.workingDirectory;
            }

            if (other.isRuntimeVersionSpecified && !isRuntimeVersionSpecified)
            {
                isRuntimeVersionSpecified = true;
                runtimeVersion = other.runtimeVersion;
            }

            foreach (string item in other.excludedTestFrameworkIds)
            {
                if (!excludedTestFrameworkIds.Contains(item))
                    excludedTestFrameworkIds.Add(item);
            }

            foreach (FileInfo item in other.files)
            {
                if (files.FindIndex(i => i.FullName == item.FullName) < 0)
                    files.Add(item);
            }

            foreach (DirectoryInfo item in other.hintDirectories)
            {
                if (hintDirectories.FindIndex(i => i.FullName == item.FullName) < 0)
                    hintDirectories.Add(item);
            }

            properties.MergeWith(other.properties);
        }
        public void CanAttachToProcessWithDebugger()
        {
            var debuggerSetup = new DebuggerSetup();
            var logger = new MarkupStreamLogger(TestLog.Default);
            var debugger = new VisualStudioDebugger(debuggerSetup, logger, null);

            ProcessStartInfo processStartInfo = CreateProcessStartInfoForDummyProcess();

            Process process = Process.Start(processStartInfo);
            try
            {
                Assert.IsFalse(debugger.IsAttachedToProcess(process), "Initially the debugger is not attached.");

                Assert.AreEqual(AttachDebuggerResult.Attached, debugger.AttachToProcess(process),
                    "Should attach to process.");
                Assert.IsTrue(debugger.IsAttachedToProcess(process), "Should report that it has attached to process.");
                Assert.AreEqual(AttachDebuggerResult.AlreadyAttached, debugger.AttachToProcess(process),
                    "Should report that it was already attached to process.");

                /* This fails because Visual Studio returns "The requested operation is not supported."
                 * It seems to be related to having the Native debugger engine attached.
                Assert.AreEqual(DetachDebuggerResult.Detached, debugger.DetachFromProcess(process), "Should detach from process.");
                Assert.IsFalse(debugger.IsAttachedToProcess(process), "Finally the debugger is not attached.");
                Assert.AreEqual(DetachDebuggerResult.AlreadyDetached, debugger.DetachFromProcess(process), "Should report that it was already detached from process.");
                 */
            }
            finally
            {
                process.Kill();
            }
        }
 /// <summary>
 /// Derived types are resposible for creating an returning a <see cref="IProcess"/> instance.
 /// The return value must represent a running AutoCAD process cabable of receiving messages.
 /// </summary>
 /// <param name="debuggerSetup">The debugger setup or null if the debugger shouldn't be used.</param>
 /// <returns>A <see cref="IProcess"/> instance.</returns>
 protected abstract IProcess StartProcess(DebuggerSetup debuggerSetup);
        /// <inheritdoc/>
        public void Start(string ipcPortName, Guid linkId, DebuggerSetup debuggerSetup)
        {
            if (ipcPortName == null)
                throw new ArgumentNullException("ipcPortName");

            var process = StartProcess(debuggerSetup);
            if (process == null)
                throw new InvalidOperationException("Unable to acquire AutoCAD process.");
            if (process.HasExited)
                throw new InvalidOperationException("Process has exited before assembly could be loaded.");

            NetLoadPlugin(process);

            // Run the create endpoint command asynchronously. This command runs for the duration of the test run.
            activeCommand = commandRunner.BeginRun(new CreateEndpointAndWaitCommand(ipcPortName, linkId), process, null, null);
        }
Beispiel #14
0
        /// <inheritdoc />
        public IDebugger GetDebugger(DebuggerSetup debuggerSetup)
        {
            if (debuggerSetup == null)
                throw new ArgumentNullException("debuggerSetup");

            return new VisualStudioDebugger(debuggerSetup, logger, this);
        }
Beispiel #15
0
 /// <summary>
 /// Creates a copy of the options.
 /// </summary>
 /// <returns>The copy.</returns>
 public DebuggerSetup Copy()
 {
     var copy = new DebuggerSetup();
     copy.properties.AddAll(properties);
     return copy;
 }
 public HostProcessTask(string executablePath, string arguments, string workingDirectory, DebuggerSetup debuggerSetup, ILogger logger)
     : base(executablePath, arguments, workingDirectory)
 {
     this.debuggerSetup = debuggerSetup;
     this.logger = logger;
 }
 /// <inheritdoc/>
 protected override IProcess StartProcess(DebuggerSetup debuggerSetup)
 {
     return process;
 }