3
3
4
4
#nullable disable
5
5
6
+ using System . Runtime . CompilerServices ;
7
+
6
8
namespace Microsoft . DotNet . Watch . UnitTests
7
9
{
8
- internal sealed class WatchableApp ( ITestOutputHelper logger ) : IDisposable
10
+ internal sealed class WatchableApp ( DebugTestOutputLogger logger ) : IDisposable
9
11
{
10
12
// Test apps should output this message as soon as they start running:
11
13
private const string StartedMessage = "Started" ;
@@ -18,7 +20,7 @@ internal sealed class WatchableApp(ITestOutputHelper logger) : IDisposable
18
20
19
21
public TestFlags TestFlags { get ; private set ; }
20
22
21
- public ITestOutputHelper Logger => logger ;
23
+ public DebugTestOutputLogger Logger => logger ;
22
24
23
25
public AwaitableProcess Process { get ; private set ; }
24
26
@@ -32,32 +34,32 @@ public static string GetLinePrefix(MessageDescriptor descriptor, string projectD
32
34
=> $ "dotnet watch { descriptor . Emoji } { ( projectDisplay != null ? $ " [{ projectDisplay } ]" : "" ) } { descriptor . Format } ";
33
35
34
36
public void AssertOutputContains ( string message )
35
- => AssertEx . Contains ( message , Process . Output ) ;
37
+ => AssertEx . ContainsSubstring ( message , Process . Output ) ;
36
38
37
39
public void AssertOutputDoesNotContain ( string message )
38
- => AssertEx . DoesNotContain ( message , Process . Output ) ;
40
+ => Assert . DoesNotContain ( Process . Output , line => line . Contains ( message ) ) ;
39
41
40
42
public void AssertOutputContains ( MessageDescriptor descriptor , string projectDisplay = null )
41
43
=> AssertOutputContains ( GetLinePrefix ( descriptor , projectDisplay ) ) ;
42
44
43
- public async ValueTask WaitUntilOutputContains ( string message )
45
+ public async ValueTask WaitUntilOutputContains ( string message , [ CallerFilePath ] string testPath = null , [ CallerLineNumber ] int testLine = 0 )
44
46
{
45
47
if ( ! Process . Output . Any ( line => line . Contains ( message ) ) )
46
48
{
47
- Logger . WriteLine ( $ "[TEST] Test waiting for output: '{ message } '") ;
49
+ Logger . Log ( $ "Test waiting for output: '{ message } '", testPath , testLine ) ;
48
50
_ = await AssertOutputLine ( line => line . Contains ( message ) ) ;
49
51
}
50
52
}
51
53
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 ) ;
54
56
55
57
/// <summary>
56
58
/// Asserts that the watched process outputs a line starting with <paramref name="expectedPrefix"/> and returns the remainder of that line.
57
59
/// </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 )
59
61
{
60
- Logger . WriteLine ( $ "[TEST] Test waiting for output: '{ expectedPrefix } '") ;
62
+ Logger . Log ( $ "Test waiting for output: '{ expectedPrefix } '", testPath , testLine ) ;
61
63
62
64
var line = await Process . GetOutputLineAsync (
63
65
success : line => line . StartsWith ( expectedPrefix , StringComparison . Ordinal ) ,
0 commit comments