Skip to content

Commit 60b6f07

Browse files
jongallowayCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 0782692 commit 60b6f07

1 file changed

Lines changed: 112 additions & 112 deletions

File tree

tests/DiagramForge.Tests/Parsers/ConceptualDslParserTests.cs

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -93,118 +93,118 @@ public void Parse_Matrix_WithCrLfLineEndings_ProducesFourQuadrantNodes()
9393
Assert.Equal("Col 2\nRow B", diagram.Nodes["cell_1_1"].Label.Text);
9494
}
9595

96-
[Fact]
97-
public void Parse_Matrix_CellsWithIconDirective_SetIconRefOnNodes()
98-
{
99-
const string text = """
100-
diagram: matrix
101-
rows:
102-
- Important
103-
- Not Important
104-
columns:
105-
- Urgent
106-
- Not Urgent
107-
cells:
108-
- icon:builtin:cloud
109-
-
110-
- icon:heroicons:shield-check
111-
- [icon:builtin:database]
112-
""";
113-
114-
var diagram = _parser.Parse(text);
115-
116-
Assert.Equal("builtin:cloud", diagram.Nodes["cell_0_0"].IconRef);
117-
Assert.Null(diagram.Nodes["cell_0_1"].IconRef);
118-
Assert.Equal("heroicons:shield-check", diagram.Nodes["cell_1_0"].IconRef);
119-
Assert.Equal("builtin:database", diagram.Nodes["cell_1_1"].IconRef);
120-
Assert.Equal("Urgent\nImportant", diagram.Nodes["cell_0_0"].Label.Text);
121-
}
122-
123-
[Fact]
124-
public void Parse_Matrix_WithoutCellsSection_LeavesIconRefsUnset()
125-
{
126-
const string text = """
127-
diagram: matrix
128-
rows:
129-
- Important
130-
- Not Important
131-
columns:
132-
- Urgent
133-
- Not Urgent
134-
""";
135-
136-
var diagram = _parser.Parse(text);
137-
138-
Assert.All(diagram.Nodes.Values, node => Assert.Null(node.IconRef));
139-
}
140-
141-
[Fact]
142-
public void Parse_Matrix_PartialCellsList_LeavesRemainingCellsWithoutIcons()
143-
{
144-
const string text = """
145-
diagram: matrix
146-
rows:
147-
- Important
148-
- Not Important
149-
columns:
150-
- Urgent
151-
- Not Urgent
152-
cells:
153-
- icon:builtin:cloud
154-
- icon:builtin:database
155-
""";
156-
157-
var diagram = _parser.Parse(text);
158-
159-
Assert.Equal("builtin:cloud", diagram.Nodes["cell_0_0"].IconRef);
160-
Assert.Equal("builtin:database", diagram.Nodes["cell_0_1"].IconRef);
161-
Assert.Null(diagram.Nodes["cell_1_0"].IconRef);
162-
Assert.Null(diagram.Nodes["cell_1_1"].IconRef);
163-
}
164-
165-
[Fact]
166-
public void Parse_Matrix_NonEmptyCellWithoutIconDirective_ThrowsDiagramParseException()
167-
{
168-
const string text = """
169-
diagram: matrix
170-
rows:
171-
- Important
172-
- Not Important
173-
columns:
174-
- Urgent
175-
- Not Urgent
176-
cells:
177-
- cloud
178-
""";
179-
180-
var ex = Assert.Throws<DiagramParseException>(() => _parser.Parse(text));
181-
182-
Assert.Contains("must be blank or contain an icon directive", ex.Message);
183-
}
184-
185-
[Fact]
186-
public void Parse_Matrix_WithTooManyCellsEntries_ThrowsDiagramParseException()
187-
{
188-
const string text = """
189-
diagram: matrix
190-
rows:
191-
- Important
192-
- Not Important
193-
columns:
194-
- Urgent
195-
- Not Urgent
196-
cells:
197-
- icon:builtin:cloud
198-
- icon:builtin:database
199-
- icon:heroicons:shield-check
200-
- icon:builtin:server
201-
- icon:builtin:fire
202-
""";
203-
204-
var ex = Assert.Throws<DiagramParseException>(() => _parser.Parse(text));
205-
206-
Assert.Contains("at most 4 'cells' entries", ex.Message);
207-
}
96+
[Fact]
97+
public void Parse_Matrix_CellsWithIconDirective_SetIconRefOnNodes()
98+
{
99+
const string text = """
100+
diagram: matrix
101+
rows:
102+
- Important
103+
- Not Important
104+
columns:
105+
- Urgent
106+
- Not Urgent
107+
cells:
108+
- icon:builtin:cloud
109+
-
110+
- icon:heroicons:shield-check
111+
- [icon:builtin:database]
112+
""";
113+
114+
var diagram = _parser.Parse(text);
115+
116+
Assert.Equal("builtin:cloud", diagram.Nodes["cell_0_0"].IconRef);
117+
Assert.Null(diagram.Nodes["cell_0_1"].IconRef);
118+
Assert.Equal("heroicons:shield-check", diagram.Nodes["cell_1_0"].IconRef);
119+
Assert.Equal("builtin:database", diagram.Nodes["cell_1_1"].IconRef);
120+
Assert.Equal("Urgent\nImportant", diagram.Nodes["cell_0_0"].Label.Text);
121+
}
122+
123+
[Fact]
124+
public void Parse_Matrix_WithoutCellsSection_LeavesIconRefsUnset()
125+
{
126+
const string text = """
127+
diagram: matrix
128+
rows:
129+
- Important
130+
- Not Important
131+
columns:
132+
- Urgent
133+
- Not Urgent
134+
""";
135+
136+
var diagram = _parser.Parse(text);
137+
138+
Assert.All(diagram.Nodes.Values, node => Assert.Null(node.IconRef));
139+
}
140+
141+
[Fact]
142+
public void Parse_Matrix_PartialCellsList_LeavesRemainingCellsWithoutIcons()
143+
{
144+
const string text = """
145+
diagram: matrix
146+
rows:
147+
- Important
148+
- Not Important
149+
columns:
150+
- Urgent
151+
- Not Urgent
152+
cells:
153+
- icon:builtin:cloud
154+
- icon:builtin:database
155+
""";
156+
157+
var diagram = _parser.Parse(text);
158+
159+
Assert.Equal("builtin:cloud", diagram.Nodes["cell_0_0"].IconRef);
160+
Assert.Equal("builtin:database", diagram.Nodes["cell_0_1"].IconRef);
161+
Assert.Null(diagram.Nodes["cell_1_0"].IconRef);
162+
Assert.Null(diagram.Nodes["cell_1_1"].IconRef);
163+
}
164+
165+
[Fact]
166+
public void Parse_Matrix_NonEmptyCellWithoutIconDirective_ThrowsDiagramParseException()
167+
{
168+
const string text = """
169+
diagram: matrix
170+
rows:
171+
- Important
172+
- Not Important
173+
columns:
174+
- Urgent
175+
- Not Urgent
176+
cells:
177+
- cloud
178+
""";
179+
180+
var ex = Assert.Throws<DiagramParseException>(() => _parser.Parse(text));
181+
182+
Assert.Contains("must be blank or contain an icon directive", ex.Message);
183+
}
184+
185+
[Fact]
186+
public void Parse_Matrix_WithTooManyCellsEntries_ThrowsDiagramParseException()
187+
{
188+
const string text = """
189+
diagram: matrix
190+
rows:
191+
- Important
192+
- Not Important
193+
columns:
194+
- Urgent
195+
- Not Urgent
196+
cells:
197+
- icon:builtin:cloud
198+
- icon:builtin:database
199+
- icon:heroicons:shield-check
200+
- icon:builtin:server
201+
- icon:builtin:fire
202+
""";
203+
204+
var ex = Assert.Throws<DiagramParseException>(() => _parser.Parse(text));
205+
206+
Assert.Contains("at most 4 'cells' entries", ex.Message);
207+
}
208208

209209
// ── Pyramid ───────────────────────────────────────────────────────────────
210210

0 commit comments

Comments
 (0)