33
44#nullable disable
55
6+ using System . Runtime . CompilerServices ;
7+
68namespace Microsoft . DotNet . Watch . UnitTests
79{
8- internal sealed class WatchableApp ( ITestOutputHelper logger ) : IDisposable
10+ internal sealed class WatchableApp ( DebugTestOutputLogger logger ) : IDisposable
911 {
1012 // Test apps should output this message as soon as they start running:
1113 private const string StartedMessage = "Started" ;
@@ -18,7 +20,7 @@ internal sealed class WatchableApp(ITestOutputHelper logger) : IDisposable
1820
1921 public TestFlags TestFlags { get ; private set ; }
2022
21- public ITestOutputHelper Logger => logger ;
23+ public DebugTestOutputLogger Logger => logger ;
2224
2325 public AwaitableProcess Process { get ; private set ; }
2426
@@ -32,32 +34,32 @@ public static string GetLinePrefix(MessageDescriptor descriptor, string projectD
3234 => $ "dotnet watch { descriptor . Emoji } { ( projectDisplay != null ? $ " [{ projectDisplay } ]" : "" ) } { descriptor . Format } ";
3335
3436 public void AssertOutputContains ( string message )
35- => AssertEx . Contains ( message , Process . Output ) ;
37+ => AssertEx . ContainsSubstring ( message , Process . Output ) ;
3638
3739 public void AssertOutputDoesNotContain ( string message )
38- => AssertEx . DoesNotContain ( message , Process . Output ) ;
40+ => Assert . DoesNotContain ( Process . Output , line => line . Contains ( message ) ) ;
3941
4042 public void AssertOutputContains ( MessageDescriptor descriptor , string projectDisplay = null )
4143 => AssertOutputContains ( GetLinePrefix ( descriptor , projectDisplay ) ) ;
4244
43- public async ValueTask WaitUntilOutputContains ( string message )
45+ public async ValueTask WaitUntilOutputContains ( string message , [ CallerFilePath ] string testPath = null , [ CallerLineNumber ] int testLine = 0 )
4446 {
4547 if ( ! Process . Output . Any ( line => line . Contains ( message ) ) )
4648 {
47- Logger . WriteLine ( $ "[TEST] Test waiting for output: '{ message } '") ;
49+ Logger . Log ( $ "Test waiting for output: '{ message } '", testPath , testLine ) ;
4850 _ = await AssertOutputLine ( line => line . Contains ( message ) ) ;
4951 }
5052 }
5153
52- public Task < string > AssertOutputLineStartsWith ( MessageDescriptor descriptor , string projectDisplay = null , Predicate < string > failure = null )
53- => AssertOutputLineStartsWith ( GetLinePrefix ( descriptor , projectDisplay ) , failure ) ;
54+ public Task < string > AssertOutputLineStartsWith ( MessageDescriptor descriptor , string projectDisplay = null , Predicate < string > failure = null , [ CallerFilePath ] string testPath = null , [ CallerLineNumber ] int testLine = 0 )
55+ => AssertOutputLineStartsWith ( GetLinePrefix ( descriptor , projectDisplay ) , failure , testPath , testLine ) ;
5456
5557 /// <summary>
5658 /// Asserts that the watched process outputs a line starting with <paramref name="expectedPrefix"/> and returns the remainder of that line.
5759 /// </summary>
58- public async Task < string > AssertOutputLineStartsWith ( string expectedPrefix , Predicate < string > failure = null )
60+ public async Task < string > AssertOutputLineStartsWith ( string expectedPrefix , Predicate < string > failure = null , [ CallerFilePath ] string testPath = null , [ CallerLineNumber ] int testLine = 0 )
5961 {
60- Logger . WriteLine ( $ "[TEST] Test waiting for output: '{ expectedPrefix } '") ;
62+ Logger . Log ( $ "Test waiting for output: '{ expectedPrefix } '", testPath , testLine ) ;
6163
6264 var line = await Process . GetOutputLineAsync (
6365 success : line => line . StartsWith ( expectedPrefix , StringComparison . Ordinal ) ,
0 commit comments