Skip to content

Commit ea4a9d7

Browse files
committed
test: clear CS0219 warnings (assigned-but-unused locals)
Three tests computed a local that was never used: - VT100MachineBypassTests: removed the dead foundC1 scan loop (the comment already explains it is intentionally not an assertion; the real check is against the host buffer). - ScrollablePanelBorderTests: dropped the unused childClicked handler (the test only verifies ProcessMouseEvent does not throw on a bordered panel). - TabControlTests.TabCloseRequested_DoesNotAutoRemove: assert the subscribed closeRequested stays false (adding a closable tab must not fire a close), alongside the existing tab-count assertion. Test project now builds warning-clean.
1 parent 1b71aba commit ea4a9d7

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

SharpConsoleUI.Tests/Controls/ScrollablePanelBorderTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ public void Mouse_WithBorder_ClickInsideContent_RoutesToChild()
436436
panel.BorderStyle = BorderStyle.Rounded;
437437
panel.Padding = new Padding(1, 0, 1, 0);
438438

439-
bool childClicked = false;
440439
var btn = ContainerTestHelpers.CreateButton("Click Me");
441-
btn.Click += (_, _) => childClicked = true;
442440
panel.AddControl(btn);
443441

444442
var (system, window) = ContainerTestHelpers.CreateTestEnvironment();

SharpConsoleUI.Tests/Controls/TabControlTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,9 @@ public void TabCloseRequested_DoesNotAutoRemove()
16141614
bool closeRequested = false;
16151615
tab.TabCloseRequested += (_, e) => closeRequested = true;
16161616

1617-
// Even if close is requested externally, tab should not be auto-removed
1618-
// (the event consumer must call RemoveTab)
1617+
// Adding a closable tab must not spontaneously request a close, and tabs are never
1618+
// auto-removed — the event consumer is responsible for calling RemoveTab.
1619+
Assert.False(closeRequested);
16191620
Assert.Equal(2, tab.TabCount);
16201621
}
16211622

SharpConsoleUI.Tests/Security/VT100MachineBypassTests.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,10 @@ public void VT100Machine_C1CsiViaUtf8_ReachesScreenBuffer()
3939
var vt = new VT100Machine(40, 5);
4040
vt.Process(payload);
4141

42-
// Check if U+009B ended up in any cell
43-
bool foundC1 = false;
44-
for (int x = 0; x < 40; x++)
45-
{
46-
var cell = vt.Screen.GetCell(x, 0);
47-
if (cell.Character.Value >= 0x0080 && cell.Character.Value <= 0x009F)
48-
{
49-
foundC1 = true;
50-
break;
51-
}
52-
}
53-
54-
// If the VT100Machine consumed the CSI internally (processed it as
55-
// a real CSI sequence and applied SGR), then no C1 in cells — the
56-
// sequence was handled. If it stored the raw C1 char, that's the vuln.
57-
//
58-
// Either way, verify no C1 controls reach the host buffer via CopyFrom:
42+
// The VT100Machine may consume the CSI internally (processed as a real CSI sequence
43+
// and SGR applied) or store the raw C1 char — either is acceptable on the screen
44+
// buffer. What matters is the security boundary: verify no C1 controls reach the
45+
// host buffer via CopyFrom.
5946
var hostBuffer = new CharacterBuffer(40, 5);
6047
hostBuffer.CopyFrom(vt.Screen, new LayoutRect(0, 0, 40, 5), 0, 0);
6148

0 commit comments

Comments
 (0)