示例#1
0
		public static int Main(string[] args)
		{
			ConsoleOptions options = new ConsoleOptions(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-console_%p.log", level);
            
            log.Info("NUnit-console.exe starting");

			if(!options.nologo)
				WriteCopyright();

			if(options.help)
			{
				options.Help();
				return ConsoleUi.OK;
			}
			
			if(options.NoArgs) 
			{
				Console.Error.WriteLine("fatal error: no inputs specified");
				options.Help();
				return ConsoleUi.OK;
			}
			
			if(!options.Validate())
			{
				foreach( string arg in options.InvalidArguments )
					Console.Error.WriteLine("fatal error: invalid argument: {0}", arg );
				options.Help();
				return ConsoleUi.INVALID_ARG;
			}

			// Add Standard Services to ServiceManager
			ServiceManager.Services.AddService( 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() );
            ServiceManager.Services.AddService( new TestAgency() );

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

            foreach (string parm in options.Parameters)
            {
                if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
                {
                    Console.WriteLine("File type not known: {0}", parm);
                    return ConsoleUi.INVALID_ARG;
                }
            }

			try
			{
				ConsoleUi consoleUi = new ConsoleUi();
				return consoleUi.Execute( options );
			}
			catch( FileNotFoundException ex )
			{
				Console.WriteLine( ex.Message );
				return ConsoleUi.FILE_NOT_FOUND;
			}
			catch( Exception ex )
			{
				Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
				return ConsoleUi.UNEXPECTED_ERROR;
			}
			finally
			{
				if(options.wait)
				{
					Console.Out.WriteLine("\nHit <enter> key to continue");
					Console.ReadLine();
				}

				log.Info( "NUnit-console.exe terminating" );
			}

		}
示例#2
0
		public static int Main(string[] args)
		{
			log.Info( "NUnit-console.exe starting" );

			ConsoleOptions options = new ConsoleOptions(args);

			if(!options.nologo)
				WriteCopyright();

			if(options.help)
			{
				options.Help();
				return ConsoleUi.OK;
			}
			
			if(options.NoArgs) 
			{
				Console.Error.WriteLine("fatal error: no inputs specified");
				options.Help();
				return ConsoleUi.OK;
			}
			
			if(!options.Validate())
			{
				foreach( string arg in options.InvalidArguments )
					Console.Error.WriteLine("fatal error: invalid argument: {0}", arg );
				options.Help();
				return ConsoleUi.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();

			try
			{
				ConsoleUi consoleUi = new ConsoleUi();
				return consoleUi.Execute( options );
			}
			catch( FileNotFoundException ex )
			{
				Console.WriteLine( ex.Message );
				return ConsoleUi.FILE_NOT_FOUND;
			}
			catch( Exception ex )
			{
				Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
				return ConsoleUi.UNEXPECTED_ERROR;
			}
			finally
			{
				if(options.wait)
				{
					Console.Out.WriteLine("\nHit <enter> key to continue");
					Console.ReadLine();
				}

				log.Info( "NUnit-console.exe terminating" );
			}

		}
示例#3
0
 public static int Main(string[] args)
 {
     return(ConsoleUi.Main(args));
 }
示例#4
0
        public static int Main(string[] args)
        {
            ConsoleOptions options = new ConsoleOptions(args);

            if(!options.nologo)
                WriteCopyright();

            if(options.help)
            {
                options.Help();
                return 0;
            }

            if(options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return 0;
            }

            if(!options.Validate())
            {
                Console.Error.WriteLine("fatal error: invalid arguments");
                options.Help();
                return 2;
            }

            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService( new SettingsService() );
            ServiceManager.Services.AddService( new DomainManager() );
            //ServiceManager.Services.AddService( new RecentFilesService() );
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService( new AddinRegistry() );
            ServiceManager.Services.AddService( new AddinManager() );

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

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return consoleUi.Execute( options );
            }
            catch( FileNotFoundException ex )
            {
                Console.WriteLine( ex.Message );
                return 2;
            }
            catch( BadImageFormatException ex )
            {
                Console.WriteLine( ex.Message );
                return 2;
            }
            catch( Exception ex )
            {
                Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
                return 2;
            }
            finally
            {
                if(options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }
            }
        }
示例#5
0
        public static int Main(string[] args)
        {
            ConsoleOptions options = new ConsoleOptions(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-console_%p.log", level);

            log.Info("NUnit-console.exe starting");

            if (!options.nologo)
            {
                WriteCopyright();
            }

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

            if (options.cleanup)
            {
                log.Info("Performing cleanup of shadow copy cache");
                DomainManager.DeleteShadowCopyPath();
                Console.WriteLine("Shadow copy cache emptied");
                return(ConsoleUi.OK);
            }

            if (options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return(ConsoleUi.OK);
            }

            if (!options.Validate())
            {
                foreach (string arg in options.InvalidArguments)
                {
                    Console.Error.WriteLine("fatal error: invalid argument: {0}", arg);
                }
                options.Help();
                return(ConsoleUi.INVALID_ARG);
            }

            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService(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());
            ServiceManager.Services.AddService(new TestAgency());

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

            foreach (string parm in options.Parameters)
            {
                if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
                {
                    Console.WriteLine("File type not known: {0}", parm);
                    return(ConsoleUi.INVALID_ARG);
                }
            }

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(ConsoleUi.FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(ConsoleUi.UNEXPECTED_ERROR);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }

                log.Info("NUnit-console.exe terminating");
            }
        }
示例#6
0
        public static int Main(string[] args)
        {
            log.Info("NUnit-console.exe starting");

            ConsoleOptions options = new ConsoleOptions(args);

            if (!options.nologo)
            {
                WriteCopyright();
            }

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

            if (options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return(ConsoleUi.OK);
            }

            if (!options.Validate())
            {
                foreach (string arg in options.InvalidArguments)
                {
                    Console.Error.WriteLine("fatal error: invalid argument: {0}", arg);
                }
                options.Help();
                return(ConsoleUi.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());
            ServiceManager.Services.AddService(new TestAgency());

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

            foreach (string parm in options.Parameters)
            {
                if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
                {
                    Console.WriteLine("File type not known: {0}", parm);
                    return(ConsoleUi.INVALID_ARG);
                }
            }

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(ConsoleUi.FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(ConsoleUi.UNEXPECTED_ERROR);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }

                log.Info("NUnit-console.exe terminating");
            }
        }
示例#7
0
        public static int Main(string[] args)
        {
            ConsoleOptions options = new ConsoleOptions(args);

            if (!options.nologo)
            {
                WriteCopyright();
            }

            if (options.help)
            {
                options.Help();
                return(0);
            }

            if (options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return(0);
            }

            if (!options.Validate())
            {
                Console.Error.WriteLine("fatal error: invalid arguments");
                options.Help();
                return(2);
            }


            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService(new SettingsService());
            ServiceManager.Services.AddService(new DomainManager());
            //ServiceManager.Services.AddService( new RecentFilesService() );
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());

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

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(2);
            }
            catch (BadImageFormatException ex)
            {
                Console.WriteLine(ex.Message);
                return(2);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(2);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }
            }
        }
示例#8
0
        public static int Run(string[] args)
        {
            ConsoleOptions options = new ConsoleOptions(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-console_%p.log", level);

            log.Info("NUnit-console.exe starting");

            // Add Standard Services to ServiceManager
            ServiceManager.Services.AddService(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());
            ServiceManager.Services.AddService(new TestAgency());

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

            foreach (string parm in options.Parameters)
            {
                if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
                {
                    Console.WriteLine("File type not known: {0}", parm);
                    return(ConsoleUi.INVALID_ARG);
                }
            }

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(ConsoleUi.FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(ConsoleUi.UNEXPECTED_ERROR);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }

                log.Info("NUnit-console.exe terminating");
            }
        }
示例#9
0
        public static int Main(string[] args)
        {
            NTrace.Info("NUnit-console.exe starting");

            ConsoleOptions options = new ConsoleOptions(args);

            if (!options.nologo)
            {
                WriteCopyright();
            }

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

            if (options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return(ConsoleUi.OK);
            }

            if (!options.Validate())
            {
                foreach (string arg in options.InvalidArguments)
                {
                    Console.Error.WriteLine("fatal error: invalid argument: {0}", arg);
                }
                options.Help();
                return(ConsoleUi.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 TestLoader() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());
            // TODO: Resolve conflict with gui testagency when running
            // console tests under the gui.
            //ServiceManager.Services.AddService( new TestAgency() );

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

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(ConsoleUi.FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(ConsoleUi.UNEXPECTED_ERROR);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }

                NTrace.Info("NUnit-console.exe terminating");
            }
        }