internal Document GetDocument(MetadataAsSourceFile file)
            {
                using var reader = new StreamReader(file.FilePath);
                var textBuffer = _textBufferFactoryService.CreateTextBuffer(reader, _textBufferFactoryService.TextContentType);

                Assert.True(_metadataAsSourceService.TryAddDocumentToWorkspace(file.FilePath, textBuffer));

                return(textBuffer.AsTextContainer().GetRelatedDocuments().Single());
            }
Example #2
0
            internal Document GetDocument(MetadataAsSourceFile file)
            {
                using var reader = File.OpenRead(file.FilePath);
                var stringText = EncodedStringText.Create(reader);

                Assert.True(_metadataAsSourceService.TryAddDocumentToWorkspace(file.FilePath, stringText.Container));

                return(stringText.Container.GetRelatedDocuments().Single());
            }
Example #3
0
            public static void VerifyResult(MetadataAsSourceFile file, string expected)
            {
                var actual     = File.ReadAllText(file.FilePath).Trim();
                var actualSpan = file.IdentifierLocation.SourceSpan;

                // Compare exact texts and verify that the location returned is exactly that
                // indicated by expected
                MarkupTestFile.GetSpan(expected, out expected, out var expectedSpan);
                AssertEx.EqualOrDiff(expected, actual);
                Assert.Equal(expectedSpan.Start, actualSpan.Start);
                Assert.Equal(expectedSpan.End, actualSpan.End);
            }
Example #4
0
            public void VerifyResult(MetadataAsSourceFile file, string expected, bool ignoreTrivia = true)
            {
                var actual     = File.ReadAllText(file.FilePath).Trim();
                var actualSpan = file.IdentifierLocation.SourceSpan;

                if (ignoreTrivia)
                {
                    // Compare tokens and verify location relative to the generated tokens
                    expected = GetSpaceSeparatedTokens(expected);
                    actual   = GetSpaceSeparatedTokens(actual.Insert(actualSpan.Start, "[|").Insert(actualSpan.End + 2, "|]"));
                }
                else
                {
                    // Compare exact texts and verify that the location returned is exactly that
                    // indicated by expected
                    MarkupTestFile.GetSpan(expected.TrimStart().TrimEnd(), out expected, out var expectedSpan);
                    Assert.Equal(expectedSpan.Start, actualSpan.Start);
                    Assert.Equal(expectedSpan.End, actualSpan.End);
                }

                Assert.Equal(expected, actual);
            }
            public void VerifyResult(MetadataAsSourceFile file, string expected, bool compareTokens = true)
            {
                var actual = File.ReadAllText(file.FilePath).Trim();
                var actualSpan = file.IdentifierLocation.SourceSpan;

                if (compareTokens)
                {
                    // Compare tokens and verify location relative to the generated tokens
                    expected = GetSpaceSeparatedTokens(expected);
                    actual = GetSpaceSeparatedTokens(actual.Insert(actualSpan.Start, "[|").Insert(actualSpan.End + 2, "|]"));
                }
                else
                {
                    // Compare exact texts and verify that the location returned is exactly that
                    // indicated by expected
                    TextSpan expectedSpan;
                    MarkupTestFile.GetSpan(expected.TrimStart().TrimEnd(), out expected, out expectedSpan);
                    Assert.Equal(expectedSpan.Start, actualSpan.Start);
                    Assert.Equal(expectedSpan.End, actualSpan.End);
                }

                Assert.Equal(expected, actual);
            }
Example #6
0
 public static void VerifyDocumentNotReused(MetadataAsSourceFile a, MetadataAsSourceFile b)
 => Assert.NotSame(a.FilePath, b.FilePath);
 public void VerifyDocumentReused(MetadataAsSourceFile a, MetadataAsSourceFile b)
 {
     Assert.Same(a.FilePath, b.FilePath);
 }
Example #8
0
 public GenerationResult(MetadataAsSourceFile file)
 {
     this.File = file;
 }
 public GenerationResult(MetadataAsSourceFile file)
 {
     this.File = file;
 }
            internal Document GetDocument(MetadataAsSourceFile file)
            {
                using (var reader = new StreamReader(file.FilePath))
                {
                    var textBuffer = _textBufferFactoryService.CreateTextBuffer(reader, _textBufferFactoryService.TextContentType);

                    Assert.True(_metadataAsSourceService.TryAddDocumentToWorkspace(file.FilePath, textBuffer));

                    return textBuffer.AsTextContainer().GetRelatedDocuments().Single();
                }
            }
 public void VerifyDocumentNotReused(MetadataAsSourceFile a, MetadataAsSourceFile b)
 {
     Assert.NotSame(a.FilePath, b.FilePath);
 }