File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,9 +10,6 @@ public static class TypeExtensions
1010#endif
1111 public static class StringExtensions
1212 {
13- public static bool IsNullOrWhiteSpace ( this string value )
14- {
15- return value == null || value . Trim ( ) . Length == 0 ;
16- }
13+ public static bool IsNullOrWhiteSpace ( this string value ) => string . IsNullOrEmpty ( value ) || value . Trim ( ) . Length == 0 ;
1714 }
1815}
Original file line number Diff line number Diff line change 3030using Microsoft . VisualStudio . TestPlatform . ObjectModel . Adapter ;
3131using Microsoft . VisualStudio . TestPlatform . ObjectModel . Logging ;
3232using NUnit . Engine ;
33+ using NUnit . VisualStudio . TestAdapter ;
3334using NUnit . VisualStudio . TestAdapter . Dump ;
3435using NUnit . VisualStudio . TestAdapter . Internal ;
3536using NUnit . VisualStudio . TestAdapter . NUnitEngine ;
@@ -159,14 +160,14 @@ public void TestFinished(INUnitTestEventTestCase resultNode)
159160 var result = testConverter . GetVsTestResults ( resultNode , outputNodes ?? EmptyNodes ) ;
160161 if ( settings . ConsoleOut == 1 )
161162 {
162- if ( ! string . IsNullOrEmpty ( result . ConsoleOutput ) && result . ConsoleOutput != NL )
163+ if ( ! result . ConsoleOutput . IsNullOrWhiteSpace ( ) && result . ConsoleOutput != NL )
163164 {
164165 string msg = result . ConsoleOutput ;
165166 if ( settings . UseTestNameInConsoleOutput )
166167 msg = $ "{ resultNode . Name } : { msg } ";
167168 recorder . SendMessage ( TestMessageLevel . Informational , msg ) ;
168169 }
169- if ( ! string . IsNullOrEmpty ( resultNode . ReasonMessage ) )
170+ if ( ! resultNode . ReasonMessage . IsNullOrWhiteSpace ( ) )
170171 {
171172 recorder . SendMessage ( TestMessageLevel . Informational , $ "{ resultNode . Name } : { resultNode . ReasonMessage } ") ;
172173 }
Original file line number Diff line number Diff line change @@ -106,6 +106,32 @@ public void TestFinished_CallsRecordEndCorrectly()
106106 Assert . That ( testLog . Events [ 0 ] . TestOutcome , Is . EqualTo ( TestOutcome . Passed ) ) ;
107107 }
108108
109+ /// <summary>
110+ /// Issue516
111+ /// </summary>
112+ [ TestCase ( null ) ]
113+ [ TestCase ( "" ) ]
114+ [ TestCase ( " " ) ]
115+ [ TestCase ( "\t " ) ]
116+ [ TestCase ( "\r " ) ]
117+ [ TestCase ( "\n " ) ]
118+ [ TestCase ( "\r \n " ) ]
119+ public void TestFinished_DoNotSendWhiteSpaceToMessages ( string data )
120+ {
121+ var testcase = Substitute . For < INUnitTestEventTestCase > ( ) ;
122+ testcase . Name . Returns ( $ "Test1({ data } )") ;
123+ testcase . FullName . Returns ( $ "Issue516.Tests.Test1({ data } )") ;
124+ testcase . Output . Returns ( $ "{ data } ") ;
125+ settings . ConsoleOut . Returns ( 1 ) ;
126+ listener . TestFinished ( testcase ) ;
127+ Assert . That ( testLog . Events . Count , Is . EqualTo ( 0 ) ) ;
128+
129+
130+
131+ }
132+
133+
134+
109135 [ Test ]
110136 public void TestFinished_CallsRecordResultCorrectly ( )
111137 {
You can’t perform that action at this time.
0 commit comments