Ejemplo n.º 1
0
        public async Task Test_SolutionSize()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

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

            var size = analyzer.GetSolutionSize(solution.Id);
            Assert.Equal(expected, size);
        }
Ejemplo n.º 2
0
        public async Task Test_RemoveDocument()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

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

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

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

            var length = (await document.GetSyntaxTreeAsync()).Length;
            Assert.Equal(expected - length, size);
        }
Ejemplo n.º 3
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);
        }