Beispiel #1
0
        public async Task Test_SolutionSize_Update()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

            // initialize
            await analyzer.NewSolutionSnapshotAsync(solution, CancellationToken.None);

            await AddSolutionAsync(analyzer, solution);

            // update document
            var document = solution.Projects.First().Documents.First();
            var length   = (await document.GetSyntaxTreeAsync()).Length;

            var text        = SourceText.From(new string('2', 1000));
            var newDocument = document.WithText(text);

            await analyzer.AnalyzeSyntaxAsync(newDocument, InvocationReasons.DocumentChanged, CancellationToken.None);

            var size = analyzer.GetSolutionSize(solution.Id);

            Assert.Equal(expected - length + text.Length, size);
        }
Beispiel #2
0
        public void Test_SolutionSize()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

            // initialize
            analyzer.NewSolutionSnapshotAsync(solution, CancellationToken.None).Wait();
            AddSolution(analyzer, solution);

            var size = analyzer.GetSolutionSize(solution.Id);

            Assert.Equal(expected, size);
        }
Beispiel #3
0
        public void Test_RemoveDocument()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

            // initialize
            analyzer.NewSolutionSnapshotAsync(solution, CancellationToken.None).Wait();
            AddSolution(analyzer, solution);

            // remove document
            var document = solution.Projects.First().Documents.First();

            analyzer.RemoveDocument(document.Id);

            var size = analyzer.GetSolutionSize(solution.Id);

            var length = document.GetSyntaxTreeAsync().Result.Length;

            Assert.Equal(expected - length, size);
        }