Fix StyleCop complaints.
Ron Martin committed
Jun 1, 2022 at 15:01 UTC
5d35ff01e33b8ffdab04a49ddc5927185309391a
1 file changed
+22
-14
src/test/burn/WixTestTools/LogVerifier.cs
+22
-14
@@ -14,7 +14,7 @@ namespace WixTestTools
14
public class LogVerifier
15
{
16
// Member Variables
17
- private string logFile;
17
+ private readonly string logFile;
18
19
/// <summary>
20
/// Prevent creation of LogVerifier without log file
@@ -29,12 +29,16 @@ namespace WixTestTools
29
public LogVerifier(string fileName)
30
{
31
if (null == fileName)
32
+ {
33
throw new ArgumentNullException("fileName");
34
+ }
35
36
if (!File.Exists(fileName))
37
+ {
38
throw new ArgumentException(String.Format(@"File doesn't exist:{0}", fileName), "fileName");
39
+ }
40
37
- logFile = fileName;
41
+ this.logFile = fileName;
42
}
43
44
/// <summary>
@@ -55,8 +59,8 @@ namespace WixTestTools
59
/// <returns>True if a match is found, False otherwise.</returns>
60
public bool LineByLine(Regex regex)
61
{
58
- string line = string.Empty;
59
- StreamReader sr = new StreamReader(logFile);
62
+ string line;
63
+ StreamReader sr = new StreamReader(this.logFile);
64
65
// Read from a file stream line by line.
66
while ((line = sr.ReadLine()) != null)
@@ -82,7 +86,7 @@ namespace WixTestTools
86
/// <returns>True if a match is found, False otherwise.</returns>
87
public bool LineByLine(string regex)
88
{
85
- return LineByLine(new Regex(regex));
89
+ return this.LineByLine(new Regex(regex));
90
}
91
92
@@ -115,7 +119,7 @@ namespace WixTestTools
119
/// <returns>The number of matches</returns>
120
public int EntireFileAtOnce(string regex)
121
{
118
- return EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline));
122
+ return this.EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline));
123
}
124
125
/// <summary>
@@ -127,9 +131,13 @@ namespace WixTestTools
131
public int EntireFileAtOnce(string regex, bool ignoreCase)
132
{
133
if (!ignoreCase)
130
- return EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline));
134
+ {
135
+ return this.EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline));
136
+ }
137
else
132
- return EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline | RegexOptions.IgnoreCase));
138
+ {
139
+ return this.EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline | RegexOptions.IgnoreCase));
140
+ }
141
}
142
143
/// <summary>
@@ -139,7 +147,7 @@ namespace WixTestTools
147
/// <param name="ignoreCase">Perform case insensitive match</param>
148
public void AssertTextInLog(string regex, bool ignoreCase)
149
{
142
- Assert.True(EntireFileAtOncestr(regex),
150
+ Assert.True(this.EntireFileAtOncestr(regex),
151
String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex));
152
}
153
@@ -150,7 +158,7 @@ namespace WixTestTools
158
/// <param name="ignoreCase">Perform case insensitive match</param>
159
public void AssertTextInLog(Regex regex, bool ignoreCase)
160
{
153
- Assert.True(EntireFileAtOnce(regex) >= 1,
161
+ Assert.True(this.EntireFileAtOnce(regex) >= 1,
162
String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex.ToString()));
163
}
164
@@ -161,7 +169,7 @@ namespace WixTestTools
169
/// <param name="ignoreCase">Perform case insensitive match</param>
170
public void AssertTextInLog(string regex)
171
{
164
- AssertTextInLog(regex, true);
172
+ this.AssertTextInLog(regex, true);
173
}
174
175
/// <summary>
@@ -171,7 +179,7 @@ namespace WixTestTools
179
/// <param name="ignoreCase">Perform case insensitive match</param>
180
public void AssertTextInLog(Regex regex)
181
{
174
- AssertTextInLog(regex, true);
182
+ this.AssertTextInLog(regex, true);
183
}
184
185
@@ -182,7 +190,7 @@ namespace WixTestTools
190
/// <param name="ignoreCase">Perform case insensitive match</param>
191
public void AssertTextNotInLog(Regex regex, bool ignoreCase)
192
{
185
- Assert.True(EntireFileAtOnce(regex) < 1,
193
+ Assert.True(this.EntireFileAtOnce(regex) < 1,
194
String.Format("The log contain a match to the regular expression \"{0}\" ", regex.ToString()));
195
}
196
@@ -193,7 +201,7 @@ namespace WixTestTools
201
/// <param name="ignoreCase">Perform case insensitive match</param>
202
public void AssertTextNotInLog(string regex, bool ignoreCase)
203
{
196
- Assert.False(EntireFileAtOncestr(regex),
204
+ Assert.False(this.EntireFileAtOncestr(regex),
205
String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex));
206
}
207