Ejemplo n.º 1
0
		private void WaitForFinish(ConsoleProgressState progress, ProgressState.StateValue expectedResult)
		{
			DateTime giveUpTime = DateTime.Now.AddSeconds(5);
			while (progress.State != expectedResult)
			{
				if (DateTime.Now > giveUpTime)
				{
					Assert.Fail("Didn't get expected result");
				}
				Thread.Sleep(10);
			}
		}
Ejemplo n.º 2
0
		public void LongRunningMethodUsingConsoleHandler_ProducesLog()
		{
			Assert.IsFalse((_logBuilder.ToString().Contains("99")));
			var progress = new ConsoleProgressState();
			progress.Log += new EventHandler<ProgressState.LogEvent>(OnProgressStateLog);
			BackgroundWorker cacheBuildingWork = new BackgroundWorker();
			cacheBuildingWork.DoWork += new DoWorkEventHandler(OnDoBackgroundWorkerWork);
			cacheBuildingWork.RunWorkerAsync(progress);

			WaitForFinish(progress, ProgressState.StateValue.Finished);
			// Fails about 2% of the time on TC Windows agents, likely due to the Asynchronous aspects of this test
			Assert.IsTrue(_logBuilder.ToString().Contains("99"));
		}