csharp4405de34 | 1 | using CascadeIDE.Features.Settings.DataAcquisition; |
| 2 | using CascadeIDE.Models; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public 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