Skip to content

Commit f14a112

Browse files
CopilotMalcolmnixon
andcommitted
fix: restore Context_WriteLine_Silent_DoesNotWriteToConsole test for TMPL-REQ-004
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 55dd2cf commit f14a112

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/DemaConsulting.TemplateDotNetTool.Tests/ContextTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,33 @@ public void Context_WriteLine_NotSilent_WritesToConsole()
252252
}
253253
}
254254

255+
/// <summary>
256+
/// Test WriteLine does not write to console when silent.
257+
/// </summary>
258+
[TestMethod]
259+
public void Context_WriteLine_Silent_DoesNotWriteToConsole()
260+
{
261+
// Arrange
262+
var originalOut = Console.Out;
263+
try
264+
{
265+
using var outWriter = new StringWriter();
266+
Console.SetOut(outWriter);
267+
using var context = Context.Create(["--silent"]);
268+
269+
// Act
270+
context.WriteLine("Test message");
271+
272+
// Assert
273+
var output = outWriter.ToString();
274+
Assert.DoesNotContain("Test message", output);
275+
}
276+
finally
277+
{
278+
Console.SetOut(originalOut);
279+
}
280+
}
281+
255282
/// <summary>
256283
/// Test WriteError does not write to console when silent.
257284
/// </summary>

0 commit comments

Comments
 (0)