Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
129 lines (117 loc) · 3.25 KB
/
Copy pathProgram.cs
File metadata and controls
129 lines (117 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using CommunityToolkit.Mvvm.DependencyInjection;
using StoryCADLib.Models;
using StoryCADLib.Services.API;
using StoryCADLib.Services.IoC;
int failures = 0;
Console.WriteLine("=== StoryCADLib 4.0 Headless Verification ===");
Console.WriteLine();
// Step 1: Headless initialization
Console.Write("1. Headless initialization... ");
try
{
BootStrapper.Initialise(); // headless=true by default
Console.WriteLine("PASS");
}
catch (Exception ex)
{
Console.WriteLine($"FAIL: {ex.Message}");
return 1;
}
// Step 2: DI resolution of StoryCADApi
Console.Write("2. DI resolution of StoryCADApi... ");
StoryCADApi api;
try
{
api = Ioc.Default.GetRequiredService<StoryCADApi>();
Console.WriteLine("PASS");
}
catch (Exception ex)
{
Console.WriteLine($"FAIL: {ex.Message}");
return 1;
}
// Step 3: CreateEmptyOutline
Console.Write("3. CreateEmptyOutline... ");
var createResult = await api.CreateEmptyOutline("Headless Test Story", "Test Author", "0");
if (!createResult.IsSuccess)
{
Console.WriteLine($"FAIL: {createResult.ErrorMessage}");
return 1;
}
Console.WriteLine($"PASS ({createResult.Payload.Count} element GUIDs returned)");
// Step 4: Element inspection
Console.Write("4. Element inspection... ");
var elementsResult = api.GetAllElements();
if (!elementsResult.IsSuccess)
{
Console.WriteLine($"FAIL: {elementsResult.ErrorMessage}");
return 1;
}
var elements = elementsResult.Payload;
if (elements.Count == 0)
{
Console.WriteLine("FAIL: No elements found");
return 1;
}
Console.WriteLine($"PASS ({elements.Count} elements)");
foreach (var el in elements)
{
Console.WriteLine($" - {el.Name} ({el.ElementType})");
}
// Step 5: WriteOutline
var tempPath = Path.Combine(Path.GetTempPath(), "HeadlessTest.stbx");
Console.Write($"5. WriteOutline to {tempPath}... ");
var writeResult = await api.WriteOutline(tempPath);
if (!writeResult.IsSuccess)
{
Console.WriteLine($"FAIL: {writeResult.ErrorMessage}");
failures++;
}
else if (!File.Exists(tempPath))
{
Console.WriteLine("FAIL: File was not created");
failures++;
}
else
{
Console.WriteLine($"PASS ({new FileInfo(tempPath).Length} bytes)");
}
// Step 6: OpenOutline
Console.Write("6. OpenOutline from file... ");
var openResult = await api.OpenOutline(tempPath);
if (!openResult.IsSuccess)
{
Console.WriteLine($"FAIL: {openResult.ErrorMessage}");
failures++;
}
else
{
Console.WriteLine("PASS");
}
// Step 7: Verify reopened model
Console.Write("7. Verify reopened model matches... ");
var reopenedResult = api.GetAllElements();
if (!reopenedResult.IsSuccess)
{
Console.WriteLine($"FAIL: {reopenedResult.ErrorMessage}");
failures++;
}
else if (reopenedResult.Payload.Count != elements.Count)
{
Console.WriteLine($"FAIL: Expected {elements.Count} elements, got {reopenedResult.Payload.Count}");
failures++;
}
else
{
Console.WriteLine($"PASS ({reopenedResult.Payload.Count} elements)");
}
// Cleanup
try { File.Delete(tempPath); } catch { /* best-effort */ }
Console.WriteLine();
if (failures > 0)
{
Console.WriteLine($"=== {failures} check(s) FAILED ===");
return 1;
}
Console.WriteLine("=== All checks passed ===");
return 0;