File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed
Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -7,24 +7,18 @@ public class ProgramTests
77 [ TestMethod ]
88 public void MainTest ( )
99 {
10- const string expectedInput = "Hello, World! " ;
11- const string expectedOutput = "Hello, World! " ;
10+ const string expectedOutput = "ValidInput " ;
11+ string simulatedInput = "\n \n ValidInput \n " ;
1212
13- StringReader reader = new ( expectedInput ) ;
14- StringWriter writer = new ( ) ;
15- try
16- {
17- Console . SetIn ( reader ) ;
18- Console . SetOut ( writer ) ;
19- Program . Main ( ) ;
20-
21- string actualOutput = writer . ToString ( ) . Trim ( ) ;
22- Assert . AreEqual ( expectedOutput , actualOutput ) ;
23- }
24- finally
25- {
26- reader . Dispose ( ) ;
27- writer . Dispose ( ) ;
28- }
13+ IntelliTect . TestTools . Console . ConsoleAssert . Expect (
14+ expectedOutput ,
15+ ( ) =>
16+ {
17+ using ( StringReader simulatedReader = new ( simulatedInput ) )
18+ {
19+ Console . SetIn ( simulatedReader ) ;
20+ Program . Main ( ) ;
21+ }
22+ } ) ;
2923 }
3024}
You can’t perform that action at this time.
0 commit comments