|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | | -namespace Microsoft.DotNet.Watch.UnitTests |
| 4 | +namespace Microsoft.DotNet.Watch.UnitTests; |
| 5 | + |
| 6 | +public class BrowserLaunchTests(ITestOutputHelper logger) : DotNetWatchTestBase(logger) |
5 | 7 | { |
6 | | - public class BrowserLaunchTests : DotNetWatchTestBase |
| 8 | + [Fact] |
| 9 | + public async Task LaunchesBrowserOnStart() |
7 | 10 | { |
8 | | - private const string AppName = "WatchBrowserLaunchApp"; |
9 | | - |
10 | | - public BrowserLaunchTests(ITestOutputHelper logger) |
11 | | - : base(logger) |
12 | | - { |
13 | | - } |
14 | | - |
15 | | - [Fact] |
16 | | - public async Task LaunchesBrowserOnStart() |
17 | | - { |
18 | | - var testAsset = TestAssets.CopyTestAsset(AppName) |
19 | | - .WithSource(); |
| 11 | + var testAsset = TestAssets.CopyTestAsset("WatchBrowserLaunchApp") |
| 12 | + .WithSource(); |
20 | 13 |
|
21 | | - App.Start(testAsset, [], testFlags: TestFlags.MockBrowser); |
| 14 | + App.Start(testAsset, [], testFlags: TestFlags.MockBrowser); |
22 | 15 |
|
23 | | - // check that all app output is printed out: |
24 | | - await App.WaitForOutputLineContaining("Content root path:"); |
| 16 | + // check that all app output is printed out: |
| 17 | + await App.WaitForOutputLineContaining("Content root path:"); |
25 | 18 |
|
26 | | - Assert.Contains(App.Process.Output, line => line.Contains("Application started. Press Ctrl+C to shut down.")); |
27 | | - Assert.Contains(App.Process.Output, line => line.Contains("Hosting environment: Development")); |
| 19 | + Assert.Contains(App.Process.Output, line => line.Contains("Application started. Press Ctrl+C to shut down.")); |
| 20 | + Assert.Contains(App.Process.Output, line => line.Contains("Hosting environment: Development")); |
28 | 21 |
|
29 | | - // Verify we launched the browser. |
30 | | - Assert.Contains(App.Process.Output, line => line.Contains("dotnet watch ⌚ Launching browser: https://localhost:5001")); |
31 | | - } |
| 22 | + // Verify we launched the browser. |
| 23 | + App.AssertOutputContains(MessageDescriptor.LaunchingBrowser.GetMessage("https://localhost:5001", "")); |
| 24 | + } |
32 | 25 |
|
33 | | - [Fact] |
34 | | - public async Task UsesBrowserSpecifiedInEnvironment() |
35 | | - { |
36 | | - var testAsset = TestAssets.CopyTestAsset(AppName) |
37 | | - .WithSource(); |
| 26 | + [Fact] |
| 27 | + public async Task UsesBrowserSpecifiedInEnvironment() |
| 28 | + { |
| 29 | + var testAsset = TestAssets.CopyTestAsset("WatchBrowserLaunchApp") |
| 30 | + .WithSource(); |
38 | 31 |
|
39 | | - App.EnvironmentVariables.Add("DOTNET_WATCH_BROWSER_PATH", "mycustombrowser.bat"); |
| 32 | + App.EnvironmentVariables.Add("DOTNET_WATCH_BROWSER_PATH", "mycustombrowser.bat"); |
40 | 33 |
|
41 | | - App.Start(testAsset, [], testFlags: TestFlags.MockBrowser); |
42 | | - await App.WaitForOutputLineContaining(MessageDescriptor.ConfiguredToUseBrowserRefresh); |
43 | | - await App.WaitForOutputLineContaining(MessageDescriptor.ConfiguredToLaunchBrowser); |
| 34 | + App.Start(testAsset, [], testFlags: TestFlags.MockBrowser); |
| 35 | + await App.WaitForOutputLineContaining(MessageDescriptor.ConfiguredToUseBrowserRefresh); |
| 36 | + await App.WaitForOutputLineContaining(MessageDescriptor.ConfiguredToLaunchBrowser); |
44 | 37 |
|
45 | | - // Verify we launched the browser. |
46 | | - await App.AssertOutputLineStartsWith("dotnet watch ⌚ Launching browser: mycustombrowser.bat https://localhost:5001"); |
47 | | - } |
| 38 | + // Verify we launched the browser. |
| 39 | + await App.WaitForOutputLineContaining(MessageDescriptor.LaunchingBrowser.GetMessage("mycustombrowser.bat", "https://localhost:5001")); |
48 | 40 | } |
49 | 41 | } |
0 commit comments