AvalonStudio.TestFrameworks.Catch.CatchTestFramework.EnumerateTestsAsync C# (CSharp) Method

EnumerateTestsAsync() public method

public EnumerateTestsAsync ( IProject project ) : Task>
project IProject
return Task>
		public async Task<IEnumerable<Test>> EnumerateTestsAsync(IProject project)
		{
			var result = new List<Test>();

			if (project.TestFramework != null && project.TestFramework is CatchTestFramework)
			{
				var startInfo = new ProcessStartInfo();
				startInfo.FileName = Path.Combine(project.CurrentDirectory, project.Executable).ToPlatformPath();
				startInfo.Arguments = "--list-test-names-only";

				// Hide console window
				startInfo.UseShellExecute = false;
				startInfo.RedirectStandardOutput = true;
				startInfo.CreateNoWindow = true;

				await Task.Factory.StartNew(() =>
				{
					using (var process = Process.Start(startInfo))
					{
						process.OutputDataReceived += (sender, e) =>
						{
							if (!string.IsNullOrEmpty(e.Data))
							{
								result.Add(new Test(project) {Name = e.Data});
							}
						};

						process.BeginOutputReadLine();

						process.WaitForExit();
					}
				});
			}

			return result;
		}