@@ -109,7 +109,8 @@ public void StaticWriteLine_FormatsLogMessageCorrectly()
109
109
110
110
// Act - Using reflection to call internal static method
111
111
typeof ( ConsoleWrapper )
112
- . GetMethod ( "WriteLine" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static , null , new [ ] { typeof ( string ) , typeof ( string ) } , null )
112
+ . GetMethod ( "WriteLine" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static ,
113
+ null , new [ ] { typeof ( string ) , typeof ( string ) } , null )
113
114
? . Invoke ( null , new object [ ] { "INFO" , "Test log message" } ) ;
114
115
115
116
// Assert
@@ -123,16 +124,73 @@ public void ClearOutputResetFlag_ResetsFlag()
123
124
// Arrange
124
125
var consoleWrapper = new ConsoleWrapper ( ) ;
125
126
ConsoleWrapper . SetOut ( _writer ) ;
126
-
127
+
127
128
// Act
128
129
consoleWrapper . WriteLine ( "First message" ) ; // Should set the reset flag
129
130
ConsoleWrapper . ClearOutputResetFlag ( ) ;
130
131
consoleWrapper . WriteLine ( "Second message" ) ; // Should set it again
131
-
132
+
132
133
// Assert
133
134
Assert . Equal ( $ "First message{ Environment . NewLine } Second message{ Environment . NewLine } ", _writer . ToString ( ) ) ;
134
135
}
135
136
137
+ [ Fact ]
138
+ public void Debug_InTestMode_WritesToTestOutputStream ( )
139
+ {
140
+ // Arrange
141
+ var consoleWrapper = new ConsoleWrapper ( ) ;
142
+ ConsoleWrapper . SetOut ( _writer ) ;
143
+
144
+ // Act
145
+ consoleWrapper . Debug ( "debug message" ) ;
146
+
147
+ // Assert
148
+ Assert . Equal ( $ "debug message{ Environment . NewLine } ", _writer . ToString ( ) ) ;
149
+ }
150
+
151
+ [ Fact ]
152
+ public void Debug_NotInTestMode_WritesToDebugConsole ( )
153
+ {
154
+ // Since capturing Debug output is difficult in a unit test
155
+ // We'll use a mock or just verify the path doesn't throw
156
+
157
+ // Arrange
158
+ var consoleWrapper = new ConsoleWrapper ( ) ;
159
+ ConsoleWrapper . ResetForTest ( ) ; // Ensure we're not in test mode
160
+
161
+ // Act & Assert - Just verify it doesn't throw
162
+ var exception = Record . Exception ( ( ) => consoleWrapper . Debug ( "debug message" ) ) ;
163
+ Assert . Null ( exception ) ;
164
+ }
165
+
166
+ [ Fact ]
167
+ public void Error_DoesNotThrowWhenNotOverridden ( )
168
+ {
169
+ // Arrange
170
+ var consoleWrapper = new ConsoleWrapper ( ) ;
171
+ ConsoleWrapper . ResetForTest ( ) ; // Reset to ensure _override is false
172
+
173
+ // Act & Assert - Just verify it doesn't throw
174
+ var exception = Record . Exception ( ( ) => consoleWrapper . Error ( "error without override" ) ) ;
175
+ Assert . Null ( exception ) ;
176
+ }
177
+
178
+ [ Fact ]
179
+ public void Error_UsesTestOutputStreamWhenInTestMode ( )
180
+ {
181
+ // Arrange
182
+ var consoleWrapper = new ConsoleWrapper ( ) ;
183
+
184
+ // Set test mode
185
+ ConsoleWrapper . SetOut ( _writer ) ;
186
+
187
+ // Act
188
+ consoleWrapper . Error ( "error in test mode" ) ;
189
+
190
+ // Assert
191
+ Assert . Contains ( "error in test mode" , _writer . ToString ( ) ) ;
192
+ }
193
+
136
194
public void Dispose ( )
137
195
{
138
196
ConsoleWrapper . ResetForTest ( ) ;
0 commit comments