Esempio n. 1
0
        public UnitTestSection()
        {
            var layout = new DynamicLayout();
            var button = new Button {
                Text = "Start Tests"
            };

            layout.Add(null);
            layout.Add(button);
            layout.Add(null);

            Content = layout;

            button.Click += (s, e) =>
            {
                button.Enabled = false;
                var thread = new Thread(() =>
                {
                    using (Generator.ThreadStart())
                    {
                        var oldOut      = Console.Out;
                        var oldErr      = Console.Error;
                        var output      = new EventStringWriter();
                        output.Flushed += val => Application.Instance.Invoke(() =>
                        {
                            foreach (var line in val.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                Log.Write(null, line);
                            }
                            output.Clear();
                        });
                        Console.SetOut(output);
                        Console.SetError(output);
                        try
                        {
                            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                                                        #if DESKTOP
                            var consoleRunner = NUnit.ConsoleRunner.Runner.Main(new[]
                            {
                                "-noshadow",
                                "-nothread",
                                "-nologo",
                                "-nodots",
                                "-domain=None",
                                "-work=" + dir,
                                typeof(Eto.Test.UnitTests.Startup).Assembly.Location
                            });
                                                        #endif
                        }
                        finally
                        {
                            Console.SetOut(oldOut);
                            Console.SetError(oldErr);
                            Application.Instance.Invoke(() => button.Enabled = true);
                        }
                    }
                });
                thread.Start();
            };
        }
Esempio n. 2
0
		public UnitTestSection()
		{
			var layout = new DynamicLayout();
			var button = new Button { Text = "Start Tests" };
			layout.Add(null);
			layout.Add(button);
			layout.Add(null);

			Content = layout;

			button.Click += (s, e) =>
			{
				button.Enabled = false;
				var thread = new Thread(() =>
				{
					using (Generator.ThreadStart())
					{
						var oldOut = Console.Out;
						var oldErr = Console.Error;
						var output = new EventStringWriter();
						output.Flushed += val => Application.Instance.Invoke(() =>
						{
							foreach (var line in val.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
								Log.Write(null, line);
							output.Clear();
						});
						Console.SetOut(output);
						Console.SetError(output);
						try
						{
							var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
							#if DESKTOP
							var consoleRunner = NUnit.ConsoleRunner.Runner.Main(new[]
							{
								"-noshadow",
								"-nothread",
								"-nologo",
								"-nodots",
								"-domain=None",
								"-work=" + dir,
								typeof(Eto.Test.UnitTests.Startup).Assembly.Location
							});
							#endif
						}
						finally
						{
							Console.SetOut(oldOut);
							Console.SetError(oldErr);
							Application.Instance.Invoke(() => button.Enabled = true);
						}
					}
				});
				thread.Start();
			};
		}