Exemple #1
0
        public Task <int> Run(string[] arguments)
        {
            var      args       = new List <string> (arguments);
            Assembly guiUnitAsm = null;

            foreach (var ar in args)
            {
                if ((ar.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || ar.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && File.Exists(ar))
                {
                    try {
                        var path = Path.GetFullPath(ar);
                        var asm  = Assembly.LoadFrom(path);
                        var ids  = new HashSet <string> ();
                        foreach (var aname in asm.GetReferencedAssemblies())
                        {
                            if (aname.Name == "GuiUnit")
                            {
                                guiUnitAsm = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(path), "GuiUnit.exe"));
                                continue;
                            }
                            ids.UnionWith(GetAddinsFromReferences(aname));
                        }

                        foreach (var id in ids)
                        {
                            AddinManager.LoadAddin(new ConsoleProgressStatus(false), id);
                        }
                    } catch (Exception ex) {
                        Console.WriteLine(ex);
                    }
                }
            }

            // Make sure the updater is disabled while running tests
            Runtime.Preferences.EnableUpdaterForCurrentSession = false;

            if (guiUnitAsm != null)
            {
                Xwt.XwtSynchronizationContext.AutoInstall = false;
                var sc = new Xwt.XwtSynchronizationContext();
                System.Threading.SynchronizationContext.SetSynchronizationContext(sc);
                Runtime.MainSynchronizationContext = sc;
                var method = guiUnitAsm.EntryPoint;
                return(Task.FromResult((int)method.Invoke(null, new [] { args.ToArray() })));
            }
            args.RemoveAll(a => a.StartsWith("-port=", StringComparison.Ordinal));
            args.Add("-domain=None");
            return(Task.FromResult(NUnit.ConsoleRunner.Runner.Main(args.ToArray())));
        }
Exemple #2
0
		public Task<int> Run (string[] arguments)
		{
			var args = new List<string> (arguments);
			Assembly guiUnitAsm = null;
			foreach (var ar in args) {
				if ((ar.EndsWith (".dll", StringComparison.OrdinalIgnoreCase) || ar.EndsWith (".exe", StringComparison.OrdinalIgnoreCase)) && File.Exists (ar)) {
					try {
						var path = Path.GetFullPath (ar);
						var asm = Assembly.LoadFrom (path);
						var ids = new HashSet<string> ();
						foreach (var aname in asm.GetReferencedAssemblies ()) {
							if (aname.Name == "GuiUnit") {
								guiUnitAsm = Assembly.LoadFile (Path.Combine (Path.GetDirectoryName (path), "GuiUnit.exe"));
								continue;
							}
							ids.UnionWith (GetAddinsFromReferences (aname));
						}

						foreach (var id in ids)
							AddinManager.LoadAddin (new ConsoleProgressStatus (false), id);

					} catch (Exception ex) {
						Console.WriteLine (ex);
					}
				}
			}
			if (guiUnitAsm != null) {
				Xwt.XwtSynchronizationContext.AutoInstall = false;
				var sc = new Xwt.XwtSynchronizationContext ();
				System.Threading.SynchronizationContext.SetSynchronizationContext (sc);
				Runtime.MainSynchronizationContext = sc;
				var runnerType = guiUnitAsm.GetType ("GuiUnit.TestRunner");
				var method = runnerType.GetMethod ("Main", BindingFlags.Public | BindingFlags.Static);
				return Task.FromResult ((int)method.Invoke (null, new [] { args.ToArray () }));
			}
			args.RemoveAll (a => a.StartsWith ("-port=", StringComparison.Ordinal));
			args.Add ("-domain=None");
			return Task.FromResult (NUnit.ConsoleRunner.Runner.Main (args.ToArray ()));
		}