GetCodeWithMarkers() 공개 메소드

public GetCodeWithMarkers ( IEnumerable spans ) : string
spans IEnumerable
리턴 string
        protected void HasDiagnostics(ProcessedCode processed, string diagnosticId)
        {
            var document = processed.Document;
            var spans    = processed.Spans;

            Assert.That(spans.Count, Is.GreaterThan(0), "At least one marker '[| |]' should be provided.");

            var diagnostics = GetDiagnostics(document);

            Console.WriteLine($"Got {diagnostics.Length} diagnostics:");
            Console.WriteLine(string.Join("\r\n", diagnostics));

            string expected = processed.GetCodeWithMarkers(diagnostics.Select(d => d.Location.SourceSpan).ToList());

            var message = $"Expected {spans.Count} diagnostic(s). Document with diagnostics:\r\n{expected}";

            Assert.That(diagnostics.Length, Is.EqualTo(spans.Count), message);

            var spanSet = new HashSet <TextSpan>(spans);

            foreach (var diagnostic in diagnostics)
            {
                Assert.That(diagnostic.Id, Is.EqualTo(diagnosticId));
                Assert.IsTrue(diagnostic.Location.IsInSource);
                Assert.IsTrue(spanSet.Contains(diagnostic.Location.SourceSpan), $"Can't find expected span. Expected:\r\n{expected}");
            }
        }
        protected void HasDiagnostics(ProcessedCode processed, string diagnosticId)
        {
            var document = processed.Document;
            var spans    = processed.Spans;

            var    diagnostics = GetDiagnostics(document);
            string expected    = processed.GetCodeWithMarkers(diagnostics.Select(d => d.Location.SourceSpan).ToList());

            var message = $"Expected {spans.Count} diagnostic(s). Document with diagnostics:\r\n{expected}";

            Assert.That(diagnostics.Length, Is.EqualTo(spans.Count), message);

            var spanSet = new HashSet <TextSpan>(spans);

            foreach (var diagnostic in diagnostics)
            {
                Assert.That(diagnostic.Id, Is.EqualTo(diagnosticId));
                Assert.IsTrue(diagnostic.Location.IsInSource);
                Assert.IsTrue(spanSet.Contains(diagnostic.Location.SourceSpan), $"{expected}");
            }
        }