Forge
csharpdeeb25a2
1using CascadeIDE.Features.Editor.Application.Monaco;
2using CascadeIDE.ViewModels;
3using Xunit;
4
5namespace CascadeIDE.Tests;
6
7public sealed class DockDocumentMonacoTextResolverTests
8{
9 [Fact]
10 public void InactiveTab_UsesDocumentContent_NotSharedEditorText()
11 {
12 var doc = new OpenDocumentViewModel(@"C:\a\B.cs", "B.cs", "class B {}");
13 var dock = new DockDocumentViewModel(doc);
14 var vm = new MainWindowViewModel
15 {
16 CurrentFilePath = @"C:\a\A.cs",
17 EditorText = "class A {}",
18 };
19
20 var text = DockDocumentMonacoTextResolver.Resolve(
21 isActive: false,
22 vm.CurrentFilePath,
23 vm.EditorText,
24 dock.Doc.FilePath,
25 dock.Doc.Content);
26
27 Assert.Equal("class B {}", text);
28 }
29
30 [Fact]
31 public void ActiveTab_WithMatchingPath_UsesEditorText()
32 {
33 var path = @"C:\a\A.cs";
34 var doc = new OpenDocumentViewModel(path, "A.cs", "stale");
35 var dock = new DockDocumentViewModel(doc);
36 var vm = new MainWindowViewModel
37 {
38 CurrentFilePath = path,
39 EditorText = "live buffer",
40 };
41
42 var text = DockDocumentMonacoTextResolver.Resolve(
43 isActive: true,
44 vm.CurrentFilePath,
45 vm.EditorText,
46 dock.Doc.FilePath,
47 dock.Doc.Content);
48
49 Assert.Equal("live buffer", text);
50 }
51
52 [Fact]
53 public void ActiveTab_PathMismatch_UsesDocumentContent()
54 {
55 var doc = new OpenDocumentViewModel(@"C:\a\B.cs", "B.cs", "class B {}");
56 var dock = new DockDocumentViewModel(doc);
57 var vm = new MainWindowViewModel
58 {
59 CurrentFilePath = @"C:\a\A.cs",
60 EditorText = "class A {}",
61 };
62
63 var text = DockDocumentMonacoTextResolver.Resolve(
64 isActive: true,
65 vm.CurrentFilePath,
66 vm.EditorText,
67 dock.Doc.FilePath,
68 dock.Doc.Content);
69
70 Assert.Equal("class B {}", text);
71 }
72}
73
View only · write via MCP/CIDE