ArchiMetrics.Analysis.Tests.CoverageAnalyzerTests.CanFindCoverage C# (CSharp) Method

CanFindCoverage() private method

private CanFindCoverage ( ) : Task
return Task
		public async Task CanFindCoverage()
		{
			var code = @"namespace MyCode
{
	public class MyClass
	{
		public string Get(int value)
		{
			return GetInternal(value);
		}

		private string GetInternal(int value)
		{
			return value.ToString();
		}
	}
}";

			var test = @"namespace MyTest
{
	using MyCode;

	public class MyTestClass
	{
		[Fact]
		public void MyTest()
		{
			var item = new MyClass();
			var x = item.Get(1);
		}
	}
}";

			var solution = CreateSolution(code, test);
			var projectCompilations = (from project in solution.Projects
									   let compilation = project.GetCompilationAsync()
									   select new
											  {
												  Documents = project.Documents.Select(
													  x => new
														   {
															   Tree = x.GetSyntaxTreeAsync(),
															   Root = x.GetSyntaxRootAsync()
														   }),
												  Compilation = compilation
											  })
				.AsArray();
			await Task.WhenAll(
				projectCompilations.SelectMany(x => x.Documents.SelectMany(y => new Task[] { y.Root, y.Tree })));

			var matches = (from x in projectCompilations
						   from doc in x.Documents
						   let model = x.Compilation.Result.GetSemanticModel(doc.Tree.Result)
						   let root = doc.Root.Result
						   from method in root.DescendantNodes()
							   .OfType<MethodDeclarationSyntax>()
						   where !method.AttributeLists.Any(
							   a => a.Attributes.Any(
								   b => b.Name.ToString()
											.IsKnownTestAttribute()))
						   select model.GetDeclaredSymbol(method))
				.AsArray();

			var analyzer = new CoverageAnalyzer(solution);
			var areReferencedTasks = matches.Select(analyzer.IsReferencedInTest).AsArray();
			var areReferenced = await Task.WhenAll(areReferencedTasks);

			Assert.True(areReferenced.All(x => x));
		}