예제 #1
0
        private static StartupAction GetStartupAction(TestIsolationOptions options, IAcadPreferenceManager preferenceManager)
        {
            // Startup actions from test isolation options take precedence.
            var attach = GetAttachOption(options);

            if (attach.HasValue && attach.Value)
            {
                return(StartupAction.AttachToExisting);
            }

            var executable = options.Properties.GetValue("AcadExePath");

            if (!string.IsNullOrEmpty(executable))
            {
                return(StartupAction.StartUserSpecified);
            }

            // Fall back to preference manager, ensuring that "AcadAttachToExisting=false" is honored.
            var preference = preferenceManager.StartupAction;

            if (preference == StartupAction.AttachToExisting && attach.HasValue)
            {
                return(StartupAction.StartMostRecentlyUsed);
            }

            return(preference);
        }
예제 #2
0
        public void SetUp()
        {
            var logger = MockRepository.GenerateStub <ILogger>();

            var fileSystem = MockRepository.GenerateStub <IFileSystem>();

            fileSystem.Stub(x => x.FileExists(Arg.Is(@"c:\path\to\acad.exe"))).Return(true);
            fileSystem.Stub(x => x.FileExists(Arg.Is(@"c:\most\recently\used\acad.exe"))).Return(true);
            fileSystem.Stub(x => x.DirectoryExists(Arg.Is(@"c:\working\dir\"))).Return(true);

            processFinder = new FakeProcessFinder();
            var debuggerManager = MockRepository.GenerateStub <IDebuggerManager>();
            var processCreator  = MockRepository.GenerateStub <IProcessCreator>();

            preferenceManager = MockRepository.GenerateStub <IAcadPreferenceManager>();

            var acadLocator = MockRepository.GenerateStub <IAcadLocator>();

            acadLocator.Stub(x => x.GetMostRecentlyUsed()).Return(@"c:\most\recently\used\acad.exe");

            var pluginLocator = MockRepository.GenerateStub <IAcadPluginLocator>();

            factory = new AcadProcessFactory(logger, fileSystem, processFinder,
                                             processCreator, debuggerManager, preferenceManager, acadLocator, pluginLocator);
        }
예제 #3
0
        /// <summary>
        /// Intializes a new <see cref="AcadProcessFactory"/> instance.
        /// </summary>
        /// <param name="logger">An <see cref="ILogger"/> instance.</param>
        /// <param name="fileSystem">An <see cref="IFileSystem"/> instance.</param>
        /// <param name="processFinder">A process finder.</param>
        /// <param name="processCreator">A process creator.</param>
        /// <param name="debuggerManager">An <see cref="IDebuggerManager"/> instance.</param>
        /// <param name="preferenceManager">The AutoCAD preference manager.</param>
        /// <param name="acadLocator">The AutoCAD locator.</param>
        /// <param name="pluginLocator">An AutoCAD plugin locator.</param>
        public AcadProcessFactory(ILogger logger, IFileSystem fileSystem,
            IProcessFinder processFinder, IProcessCreator processCreator,
            IDebuggerManager debuggerManager, IAcadPreferenceManager preferenceManager,
            IAcadLocator acadLocator, IAcadPluginLocator pluginLocator)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (fileSystem == null)
                throw new ArgumentNullException("fileSystem");
            if (processFinder == null)
                throw new ArgumentNullException("processFinder");
            if (processCreator == null)
                throw new ArgumentNullException("processCreator");
            if (debuggerManager == null)
                throw new ArgumentNullException("debuggerManager");
            if (preferenceManager == null)
                throw new ArgumentNullException("preferenceManager");
            if (acadLocator == null)
                throw new ArgumentNullException("acadLocator");
            if (pluginLocator == null)
                throw new ArgumentNullException("pluginLocator");

            this.logger = logger;
            this.fileSystem = fileSystem;
            this.processFinder = processFinder;
            this.processCreator = processCreator;
            this.debuggerManager = debuggerManager;
            this.preferenceManager = preferenceManager;
            this.acadLocator = acadLocator;
            this.pluginLocator = pluginLocator;
        }
 /// <summary>
 /// Creates a new <see cref="StartupPreferencePaneProvider"/>.
 /// </summary>
 /// <param name="preferenceManager">The AutoCAD preference manager.</param>
 public StartupPreferencePaneProvider(IAcadPreferenceManager preferenceManager)
 {
     if (preferenceManager == null)
     {
         throw new ArgumentNullException("preferenceManager");
     }
     this.preferenceManager = preferenceManager;
 }
예제 #5
0
        private static string GetExecutable(TestIsolationOptions options, IAcadPreferenceManager preferenceManager, IAcadLocator acadLocator)
        {
            var executable = options.Properties.GetValue("AcadExePath");

            if (!string.IsNullOrEmpty(executable))
            {
                return(executable);
            }

            if (preferenceManager.StartupAction == StartupAction.StartUserSpecified)
            {
                return(preferenceManager.UserSpecifiedExecutable);
            }

            return(acadLocator.GetMostRecentlyUsed());
        }
예제 #6
0
        /// <summary>
        /// Intializes a new <see cref="AcadProcessFactory"/> instance.
        /// </summary>
        /// <param name="logger">An <see cref="ILogger"/> instance.</param>
        /// <param name="fileSystem">An <see cref="IFileSystem"/> instance.</param>
        /// <param name="processFinder">A process finder.</param>
        /// <param name="processCreator">A process creator.</param>
        /// <param name="debuggerManager">An <see cref="IDebuggerManager"/> instance.</param>
        /// <param name="preferenceManager">The AutoCAD preference manager.</param>
        /// <param name="acadLocator">The AutoCAD locator.</param>
        /// <param name="pluginLocator">An AutoCAD plugin locator.</param>
        public AcadProcessFactory(ILogger logger, IFileSystem fileSystem,
                                  IProcessFinder processFinder, IProcessCreator processCreator,
                                  IDebuggerManager debuggerManager, IAcadPreferenceManager preferenceManager,
                                  IAcadLocator acadLocator, IAcadPluginLocator pluginLocator)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (processFinder == null)
            {
                throw new ArgumentNullException("processFinder");
            }
            if (processCreator == null)
            {
                throw new ArgumentNullException("processCreator");
            }
            if (debuggerManager == null)
            {
                throw new ArgumentNullException("debuggerManager");
            }
            if (preferenceManager == null)
            {
                throw new ArgumentNullException("preferenceManager");
            }
            if (acadLocator == null)
            {
                throw new ArgumentNullException("acadLocator");
            }
            if (pluginLocator == null)
            {
                throw new ArgumentNullException("pluginLocator");
            }

            this.logger            = logger;
            this.fileSystem        = fileSystem;
            this.processFinder     = processFinder;
            this.processCreator    = processCreator;
            this.debuggerManager   = debuggerManager;
            this.preferenceManager = preferenceManager;
            this.acadLocator       = acadLocator;
            this.pluginLocator     = pluginLocator;
        }
        /// <summary>
        /// Creates a new <see cref="StartupPreferencePane"/>.
        /// </summary>
        /// <param name="preferenceManager">The AutoCAD preference manager.</param>
        public StartupPreferencePane(IAcadPreferenceManager preferenceManager)
        {
            if (preferenceManager == null)
                throw new ArgumentNullException("preferenceManager");

            isInitializing = true;
            this.preferenceManager = preferenceManager;

            InitializeComponent();

            SelectedStartupAction = preferenceManager.StartupAction;
            executable.Text = preferenceManager.UserSpecifiedExecutable;
            arguments.Text = preferenceManager.CommandLineArguments;
            workingDir.Text = preferenceManager.WorkingDirectory;

            executable.DataBindings.Add("Enabled", startSpecified, "Checked");
            executableBrowse.DataBindings.Add("Enabled", startSpecified, "Checked");

            isInitializing = false;
        }
예제 #8
0
        /// <summary>
        /// Creates a new <see cref="StartupPreferencePane"/>.
        /// </summary>
        /// <param name="preferenceManager">The AutoCAD preference manager.</param>
        public StartupPreferencePane(IAcadPreferenceManager preferenceManager)
        {
            if (preferenceManager == null)
            {
                throw new ArgumentNullException("preferenceManager");
            }

            isInitializing         = true;
            this.preferenceManager = preferenceManager;

            InitializeComponent();

            SelectedStartupAction = preferenceManager.StartupAction;
            executable.Text       = preferenceManager.UserSpecifiedExecutable;
            arguments.Text        = preferenceManager.CommandLineArguments;
            workingDir.Text       = preferenceManager.WorkingDirectory;

            executable.DataBindings.Add("Enabled", startSpecified, "Checked");
            executableBrowse.DataBindings.Add("Enabled", startSpecified, "Checked");

            isInitializing = false;
        }
        public void SetUp()
        {
            var logger = MockRepository.GenerateStub<ILogger>();

            var fileSystem = MockRepository.GenerateStub<IFileSystem>();
            fileSystem.Stub(x => x.FileExists(Arg.Is(@"c:\path\to\acad.exe"))).Return(true);
            fileSystem.Stub(x => x.FileExists(Arg.Is(@"c:\most\recently\used\acad.exe"))).Return(true);
            fileSystem.Stub(x => x.DirectoryExists(Arg.Is(@"c:\working\dir\"))).Return(true);

            processFinder = new FakeProcessFinder();
            var debuggerManager = MockRepository.GenerateStub<IDebuggerManager>();
            var processCreator = MockRepository.GenerateStub<IProcessCreator>();

            preferenceManager = MockRepository.GenerateStub<IAcadPreferenceManager>();

            var acadLocator = MockRepository.GenerateStub<IAcadLocator>();
            acadLocator.Stub(x => x.GetMostRecentlyUsed()).Return(@"c:\most\recently\used\acad.exe");

            var pluginLocator = MockRepository.GenerateStub<IAcadPluginLocator>();

            factory = new AcadProcessFactory(logger, fileSystem, processFinder,
                processCreator, debuggerManager, preferenceManager, acadLocator, pluginLocator);
        }
예제 #10
0
        private static string GetArguments(IAcadPreferenceManager manager)
        {
            var args = manager.CommandLineArguments;

            return(string.IsNullOrEmpty(args) ? null : args);
        }
예제 #11
0
        private static string GetWorkingDirectory(IAcadPreferenceManager manager)
        {
            var dir = manager.WorkingDirectory;

            return(string.IsNullOrEmpty(dir) ? null : dir);
        }
 /// <summary>
 /// Creates a new <see cref="StartupPreferencePaneProvider"/>.
 /// </summary>
 /// <param name="preferenceManager">The AutoCAD preference manager.</param>
 public StartupPreferencePaneProvider(IAcadPreferenceManager preferenceManager)
 {
     if (preferenceManager == null)
         throw new ArgumentNullException("preferenceManager");
     this.preferenceManager = preferenceManager;
 }
예제 #13
0
 private static string GetArguments(IAcadPreferenceManager manager)
 {
     var args = manager.CommandLineArguments;
     return string.IsNullOrEmpty(args) ? null : args;
 }
예제 #14
0
 private static string GetWorkingDirectory(IAcadPreferenceManager manager)
 {
     var dir = manager.WorkingDirectory;
     return string.IsNullOrEmpty(dir) ? null : dir;
 }
예제 #15
0
        private static string GetExecutable(TestIsolationOptions options, IAcadPreferenceManager preferenceManager, IAcadLocator acadLocator)
        {
            var executable = options.Properties.GetValue("AcadExePath");
            if (!string.IsNullOrEmpty(executable))
                return executable;

            if (preferenceManager.StartupAction == StartupAction.StartUserSpecified)
                return preferenceManager.UserSpecifiedExecutable;

            return acadLocator.GetMostRecentlyUsed();
        }
예제 #16
0
        private static StartupAction GetStartupAction(TestIsolationOptions options, IAcadPreferenceManager preferenceManager)
        {
            // Startup actions from test isolation options take precedence.
            var attach = GetAttachOption(options);
            if (attach.HasValue && attach.Value)
                return StartupAction.AttachToExisting;

            var executable = options.Properties.GetValue("AcadExePath");
            if (!string.IsNullOrEmpty(executable))
                return StartupAction.StartUserSpecified;

            // Fall back to preference manager, ensuring that "AcadAttachToExisting=false" is honored.
            var preference = preferenceManager.StartupAction;
            if (preference == StartupAction.AttachToExisting && attach.HasValue)
                return StartupAction.StartMostRecentlyUsed;

            return preference;
        }