Forge
csharp4405de34
1using CascadeIDE.Features.Settings.DataAcquisition;
2using CascadeIDE.Models;
3using Xunit;
4
5namespace CascadeIDE.Tests;
6
7public sealed class KbBaseOverlayPathResolverTests
8{
9 [Fact]
10 public void TryResolveCanonRoot_ReturnsNull_WhenKbDirMissingUnderOverlay()
11 {
12 var settings = new CascadeIdeSettings
13 {
14 AgentNotes = new AgentNotesSettings { KbBaseOverlayPath = "not-a-real-canon-xxxx" },
15 };
16
17 Assert.Null(KbBaseOverlayPathResolver.TryResolveCanonRoot(settings));
18 }
19
20 [Fact]
21 public void TryResolveCanonRoot_WithRelativePath_ResolvesFromSettingsDirectoryPrefix()
22 {
23 var unique = $"kb-overlay-test-{Guid.NewGuid():N}";
24 var canon = Path.Combine(UserSettingsPaths.GetSettingsDirectory(), unique);
25 var knowledgePath = Path.Combine(canon, "knowledge");
26
27 Directory.CreateDirectory(knowledgePath);
28
29 try
30 {
31 var settings = new CascadeIdeSettings
32 {
33 AgentNotes = new AgentNotesSettings { KbBaseOverlayPath = unique },
34 };
35
36 Assert.Equal(CanonicalFilePath.Normalize(canon), CanonicalFilePath.Normalize(KbBaseOverlayPathResolver.TryResolveCanonRoot(settings)!));
37 }
38 finally
39 {
40 try
41 {
42 Directory.Delete(canon, recursive: true);
43 }
44 catch
45 {
46 // тест только для короткоживущей папки
47 }
48 }
49 }
50}
51
View only · write via MCP/CIDE