| 1 | using CascadeIDE.Cockpit.DataBus; |
| 2 | using CascadeIDE.Features.HybridIndex.Application; |
| 3 | using CascadeIDE.Features.Search.Application; |
| 4 | using CascadeIDE.Models; |
| 5 | using Xunit; |
| 6 | |
| 7 | namespace CascadeIDE.Tests; |
| 8 | |
| 9 | public sealed class CommandPaletteGoToSearchBackendFactoryTests |
| 10 | { |
| 11 | [Fact] |
| 12 | public void Resolve_WhenHybridDisabled_AlwaysRipgrep_ForAnyKind() |
| 13 | { |
| 14 | using var bus = new InMemoryDataBus(asynchronousDispatch: false); |
| 15 | using var orchestrator = new HybridIndexOrchestrator(bus, ".hybrid-codebase-index"); |
| 16 | |
| 17 | var hci = CommandPaletteGoToSearchBackendFactory.Resolve( |
| 18 | CommandPaletteGoToSearchBackendKind.Hci, |
| 19 | orchestrator, |
| 20 | "workspace+solution", |
| 21 | hybridIntegrationEnabled: false); |
| 22 | |
| 23 | var auto = CommandPaletteGoToSearchBackendFactory.Resolve( |
| 24 | CommandPaletteGoToSearchBackendKind.Auto, |
| 25 | orchestrator, |
| 26 | "workspace+solution", |
| 27 | hybridIntegrationEnabled: false); |
| 28 | |
| 29 | Assert.IsType<RipgrepCommandPaletteGoToSearchBackend>(hci); |
| 30 | Assert.Same(hci, auto); |
| 31 | } |
| 32 | |
| 33 | [Fact] |
| 34 | public void Resolve_WhenHybridEnabled_Rg_ReturnsRipgrep() |
| 35 | { |
| 36 | using var bus = new InMemoryDataBus(asynchronousDispatch: false); |
| 37 | using var orchestrator = new HybridIndexOrchestrator(bus, ".hybrid-codebase-index"); |
| 38 | |
| 39 | var be = CommandPaletteGoToSearchBackendFactory.Resolve( |
| 40 | CommandPaletteGoToSearchBackendKind.Rg, |
| 41 | orchestrator, |
| 42 | "workspace+solution", |
| 43 | hybridIntegrationEnabled: true); |
| 44 | |
| 45 | Assert.IsType<RipgrepCommandPaletteGoToSearchBackend>(be); |
| 46 | } |
| 47 | |
| 48 | [Fact] |
| 49 | public void Resolve_WhenHybridEnabled_Hci_ReturnsHybridBackend() |
| 50 | { |
| 51 | using var bus = new InMemoryDataBus(asynchronousDispatch: false); |
| 52 | using var orchestrator = new HybridIndexOrchestrator(bus, ".hybrid-codebase-index"); |
| 53 | |
| 54 | var be = CommandPaletteGoToSearchBackendFactory.Resolve( |
| 55 | CommandPaletteGoToSearchBackendKind.Hci, |
| 56 | orchestrator, |
| 57 | "workspace+solution", |
| 58 | hybridIntegrationEnabled: true); |
| 59 | |
| 60 | Assert.IsType<HybridIndexCommandPaletteGoToSearchBackend>(be); |
| 61 | } |
| 62 | |
| 63 | [Fact] |
| 64 | public void Resolve_WhenHybridEnabled_Auto_ReturnsCompositeAuto() |
| 65 | { |
| 66 | using var bus = new InMemoryDataBus(asynchronousDispatch: false); |
| 67 | using var orchestrator = new HybridIndexOrchestrator(bus, ".hybrid-codebase-index"); |
| 68 | |
| 69 | var be = CommandPaletteGoToSearchBackendFactory.Resolve( |
| 70 | CommandPaletteGoToSearchBackendKind.Auto, |
| 71 | orchestrator, |
| 72 | "workspace+solution", |
| 73 | hybridIntegrationEnabled: true); |
| 74 | |
| 75 | Assert.IsType<CompositeAutoCommandPaletteGoToSearchBackend>(be); |
| 76 | } |
| 77 | } |
| 78 | |