| 1 | using CascadeIDE.Cockpit.ComputingUnits.Launch; |
| 2 | using CascadeIDE.Features.Launch.DataAcquisition; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class DebugLaunchFromProfileTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void TryGetExistingCsproj_Existing_Returns_True() |
| 11 | { |
| 12 | var root = Path.Combine(Path.GetTempPath(), "cide-dlfp-" + Guid.NewGuid().ToString("n")); |
| 13 | Directory.CreateDirectory(root); |
| 14 | try |
| 15 | { |
| 16 | var fsPath = "sub" + Path.DirectorySeparatorChar + "A.csproj"; |
| 17 | var sub = Path.Combine(root, "sub"); |
| 18 | Directory.CreateDirectory(sub); |
| 19 | File.WriteAllText(Path.Combine(sub, "A.csproj"), "<Project />"); |
| 20 | |
| 21 | Assert.True( |
| 22 | LaunchProjectPathResolver.TryGetExistingCsprojFullPath(root, fsPath, out var full) && |
| 23 | full is { Length: > 0 } && |
| 24 | File.Exists(full!)); |
| 25 | } |
| 26 | finally |
| 27 | { |
| 28 | try |
| 29 | { |
| 30 | Directory.Delete(root, true); |
| 31 | } |
| 32 | catch |
| 33 | { |
| 34 | // best-effort |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | [Fact] |
| 40 | public void NonEmptyEnvironmentOrNull_Empty_Dictionary_Returns_Null() |
| 41 | { |
| 42 | var prof = new LaunchProfileData( |
| 43 | "P", |
| 44 | "a.csproj", |
| 45 | LaunchProfilesStore.DefaultConfiguration, |
| 46 | null, |
| 47 | null, |
| 48 | new Dictionary<string, string>(StringComparer.Ordinal), |
| 49 | false, |
| 50 | null); |
| 51 | Assert.Null(DebugLaunchFromProfile.NonEmptyEnvironmentOrNull(prof)); |
| 52 | } |
| 53 | } |
| 54 | |