| Name | Message | Date |
|---|---|---|
| 📄 OpenAsyncShould.cs | 5 days ago |
📄
ui/tests/ScanSessionFactoryTests/OpenAsyncShould.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Cfa.Ui.Graph; using Cfa.Ui.Services; using Shouldly; using Xunit; namespace Cfa.Ui.Tests.ScanSessionFactoryTests; public sealed class OpenAsyncShould { [Fact] public async Task LoadTheCfaSolutionAndReuseTheSessionForSeveralQueries() { // Arrange var directory = new DirectoryInfo(AppContext.BaseDirectory); while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "code-flow-analysis.slnx"))) { directory = directory.Parent; } var root = directory.ShouldNotBeNull().FullName; var solution = new FileInfo(Path.Combine(root, "code-flow-analysis.slnx")); var source = new FileInfo(Path.Combine(root, "core/src/CompilationsExtensions.cs")); var lines = await File.ReadAllLinesAsync(source.FullName); var line = Array.FindIndex(lines, text => text.Contains("public static SemanticModel GetSemanticModel")) + 1; using var timeout = new CancellationTokenSource(TimeSpan.FromMinutes(2)); var factory = new ScanSessionFactory(); // Act using var session = await factory.OpenAsync(solution, timeout.Token); var first = await session.AnalyzeAsync(source, line, timeout.Token); var second = await session.AnalyzeAsync(source, line, timeout.Token); var scene = GraphLayout.Build(second, timeout.Token); // Assert first.Origin.Name.ShouldBe("GetSemanticModel"); second.Origin.ShouldBe(first.Origin); scene.Nodes.Where(node => node.IsOrigin).ShouldHaveSingleItem().Symbol.ShouldBe(second.Origin); } }