Forge
csharpdeeb25a2
1#nullable enable
2using System.Collections.ObjectModel;
3using System.IO;
4using CascadeIDE.Features.Launch.Application;
5using CascadeIDE.Models;
6using CascadeIDE.Services;
7using Xunit;
8
9namespace CascadeIDE.Tests;
10
11public sealed class StartupProjectDebugInferenceProjectionTests
12{
13 [Fact]
14 public void Empty_roots_yields_null()
15 {
16 var roots = new ObservableCollection<SolutionItem>();
17 Assert.Null(StartupProjectDebugInferenceProjection.TryInferCanonicalCsproj(roots, null, null));
18 }
19
20 [Fact]
21 public void Single_csproj_in_tree_is_picked()
22 {
23 var dir = Path.Combine(Path.GetTempPath(), "cide-startup-infer-" + Guid.NewGuid().ToString("N"));
24 Directory.CreateDirectory(dir);
25 var csproj = Path.Combine(dir, "Only.csproj");
26 File.WriteAllText(csproj, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>");
27
28 var roots = new ObservableCollection<SolutionItem>
29 {
30 SolutionItem.CreateProject("Only", csproj)
31 };
32
33 Assert.Equal(CanonicalFilePath.Normalize(csproj), StartupProjectDebugInferenceProjection.TryInferCanonicalCsproj(roots, null, null));
34 }
35
36 [Fact]
37 public void Persisted_startup_false_when_missing_path()
38 {
39 Assert.False(StartupProjectDebugInferenceProjection.HasPersistedStartupPointingToExistingFile(null));
40 Assert.False(StartupProjectDebugInferenceProjection.HasPersistedStartupPointingToExistingFile(""));
41 }
42
43 [Fact]
44 public void Persisted_startup_true_when_file_exists()
45 {
46 var f = Path.GetTempFileName() + ".csproj";
47 File.WriteAllText(f, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>");
48 try
49 {
50 Assert.True(StartupProjectDebugInferenceProjection.HasPersistedStartupPointingToExistingFile(f));
51 }
52 finally
53 {
54 try { File.Delete(f); } catch { /* ignore */ }
55 }
56 }
57}
58
View only · write via MCP/CIDE