Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void Test_SolutionSize_Update()
        {
            var expected = 12345;
            var solution = CreateSolution(expected);

            var analyzer = new SolutionSizeTracker.IncrementalAnalyzer();

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

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

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

            analyzer.AnalyzeSyntaxAsync(newDocument, CancellationToken.None).Wait();

            var size = analyzer.GetSolutionSize(solution.Id);
            Assert.Equal(expected - length + text.Length, size);
        }