예제 #1
0
        public static new int Main(string[] args)
        {
            CommandOptionsArxNet options = new CommandOptionsArxNet(args);

            // Create SettingsService early so we know the trace level right at the start
            SettingsService settingsService = new SettingsService();
            InternalTraceLevel level = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default);
            if (options.trace != InternalTraceLevel.Default)
                level = options.trace;

            InternalTrace.Initialize("nunit-command-arxnet_%p.log", level);

            log.Info("NUnit-command-arxnet.dll starting");

            if (!options.nologo)
                WriteCopyright();

            if (options.help)
            {
                options.Help();
                return CommandUiArxNet.OK;
            }

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            if (options.cleanup)
            {
                log.Info("Performing cleanup of shadow copy cache");
                DomainManager.DeleteShadowCopyPath();
                ed.WriteMessage("\nShadow copy cache emptied");
                return CommandUiArxNet.OK;
            }

            if (options.NoArgs)
            {
                ed.WriteMessage("\nfatal error: no inputs specified");
                options.Help();
                return CommandUiArxNet.OK;
            }

            if (!options.Validate())
            {
                foreach (string arg in options.InvalidArguments)
                    ed.WriteMessage("\nfatal error: invalid argument: {0}", arg);
                options.Help();
                return CommandUiArxNet.INVALID_ARG;
            }

            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService(new SettingsService());
            ServiceManager.Services.AddService(new DomainManager());
            //ServiceManager.Services.AddService( new RecentFilesService() );
            ServiceManager.Services.AddService(new ProjectService());
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());
            // Hack: Resolves conflict with gui testagency when running
            // console tests under the gui.
            if (!AppDomain.CurrentDomain.FriendlyName.StartsWith("test-domain-"))
                ServiceManager.Services.AddService(new TestAgency());

            // Initialize Services
            ServiceManager.Services.InitializeServices();

            foreach (string parm in options.Parameters)
            {
                if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
                {
                    ed.WriteMessage("\nFile type not known: {0}", parm);
                    return CommandUiArxNet.INVALID_ARG;
                }
            }

            try
            {
                CommandUiArxNet commandUiArxNet = new CommandUiArxNet();
                return commandUiArxNet.Execute(options);
            }
            catch (FileNotFoundException ex)
            {
                ed.WriteMessage("\n" + ex.Message);
                return CommandUiArxNet.FILE_NOT_FOUND;
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                ed.WriteMessage("\nAutoCAD Exception:\n{0}", ex.ToString());
                return CommandUiArxNet.UNEXPECTED_ERROR;
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nUnhandled Exception:\n{0}", ex.ToString());
                return CommandUiArxNet.UNEXPECTED_ERROR;
            }
            finally
            {
                if (options.wait)
                {
                    ed.GetString(new PromptStringOptions("\n\nHit <enter> key to continue"));
                }

                log.Info("NUnit-command-arxnet.dll terminating");
            }
        }
예제 #2
0
 public void AssemblyAloneIsValid()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "nunit.tests.dll" );
     Assert.IsTrue(options.Validate(), "command line should be valid");
 }
예제 #3
0
 public void FileNameWithoutXmlParameterLooksLikeParameter()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "tests.dll", "result.xml" );
     Assert.IsTrue(options.Validate());
     Assert.AreEqual(2, options.Parameters.Count);
 }
예제 #4
0
 public void XmlParameterWithoutFileNameIsInvalid()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "tests.dll", "-xml:" );
     Assert.IsFalse(options.Validate());
 }
예제 #5
0
 public void NoFixtureNameProvided()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "-fixture:", "nunit.tests.dll" );
     Assert.IsFalse(options.Validate());
 }
예제 #6
0
 public void InvalidOption()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "-asembly:nunit.tests.dll" );
     Assert.IsFalse(options.Validate());
 }
예제 #7
0
 public void InvalidCommandLineParms()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "-garbage:TestFixture", "-assembly:Tests.dll" );
     Assert.IsFalse(options.Validate());
 }
예제 #8
0
 public void FixtureNamePlusAssemblyIsValid()
 {
     CommandOptionsArxNet options = new CommandOptionsArxNet( "-fixture:NUnit.Tests.AllTests", "nunit.tests.dll" );
     Assert.AreEqual("nunit.tests.dll", options.Parameters[0]);
     Assert.AreEqual("NUnit.Tests.AllTests", options.fixture);
     Assert.IsTrue(options.Validate());
 }