|
| 1 | +using System.Collections.Generic; |
1 | 2 | using System.Diagnostics; |
2 | 3 | using System.IO; |
3 | 4 | using System.Linq; |
@@ -130,19 +131,30 @@ public static void AssertEntryContents (this ZipArchive zip, string zipPath, str |
130 | 131 | [DebuggerHidden] |
131 | 132 | public static void AssertHasNoWarnings (this ProjectBuilder builder) |
132 | 133 | { |
133 | | - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, " 0 Warning(s)"), $"{builder.BuildLogFile} should have no MSBuild warnings."); |
| 134 | + AssertHasSomeWarnings (builder.LastBuildOutput, 0, builder.BuildLogFile); |
| 135 | + } |
| 136 | + |
| 137 | + [DebuggerHidden] |
| 138 | + public static void AssertHasSomeWarnings (this ProjectBuilder builder, uint numOfExpectedWarnings) |
| 139 | + { |
| 140 | + AssertHasSomeWarnings (builder.LastBuildOutput, numOfExpectedWarnings, builder.BuildLogFile); |
134 | 141 | } |
135 | 142 |
|
136 | 143 | [DebuggerHidden] |
137 | 144 | public static void AssertHasNoWarnings (this DotNetCLI dotnet) |
138 | 145 | { |
139 | | - Assert.IsTrue (StringAssertEx.ContainsText (dotnet.LastBuildOutput, " 0 Warning(s)"), $"{dotnet.BuildLogFile} should have no MSBuild warnings."); |
| 146 | + AssertHasSomeWarnings (dotnet.LastBuildOutput, 0, dotnet.BuildLogFile); |
140 | 147 | } |
141 | 148 |
|
142 | 149 | [DebuggerHidden] |
143 | 150 | public static void AssertHasSomeWarnings (this DotNetCLI dotnet, uint numOfExpectedWarnings) |
144 | 151 | { |
145 | | - Assert.IsTrue (StringAssertEx.ContainsText (dotnet.LastBuildOutput, $" {numOfExpectedWarnings} Warning(s)"), $"{dotnet.BuildLogFile} should have {numOfExpectedWarnings} MSBuild warnings."); |
| 152 | + AssertHasSomeWarnings (dotnet.LastBuildOutput, numOfExpectedWarnings, dotnet.BuildLogFile); |
| 153 | + } |
| 154 | + |
| 155 | + static void AssertHasSomeWarnings (IEnumerable<string> lastBuildOutput, uint numOfExpectedWarnings, string logFile) |
| 156 | + { |
| 157 | + Assert.IsTrue (StringAssertEx.ContainsText (lastBuildOutput, $" {numOfExpectedWarnings} Warning(s)"), $"{logFile} should have {numOfExpectedWarnings} MSBuild warnings."); |
146 | 158 | } |
147 | 159 | } |
148 | 160 | } |
0 commit comments