diff options
Diffstat (limited to '')
| -rw-r--r-- | src/test/burn/WixTestTools/LogVerifier.cs | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/test/burn/WixTestTools/LogVerifier.cs b/src/test/burn/WixTestTools/LogVerifier.cs index 0252a9f9..d402fad5 100644 --- a/src/test/burn/WixTestTools/LogVerifier.cs +++ b/src/test/burn/WixTestTools/LogVerifier.cs | |||
| @@ -14,7 +14,7 @@ namespace WixTestTools | |||
| 14 | public class LogVerifier | 14 | public class LogVerifier |
| 15 | { | 15 | { |
| 16 | // Member Variables | 16 | // Member Variables |
| 17 | private string logFile; | 17 | private readonly string logFile; |
| 18 | 18 | ||
| 19 | /// <summary> | 19 | /// <summary> |
| 20 | /// Prevent creation of LogVerifier without log file | 20 | /// Prevent creation of LogVerifier without log file |
| @@ -29,12 +29,16 @@ namespace WixTestTools | |||
| 29 | public LogVerifier(string fileName) | 29 | public LogVerifier(string fileName) |
| 30 | { | 30 | { |
| 31 | if (null == fileName) | 31 | if (null == fileName) |
| 32 | { | ||
| 32 | throw new ArgumentNullException("fileName"); | 33 | throw new ArgumentNullException("fileName"); |
| 34 | } | ||
| 33 | 35 | ||
| 34 | if (!File.Exists(fileName)) | 36 | if (!File.Exists(fileName)) |
| 37 | { | ||
| 35 | throw new ArgumentException(String.Format(@"File doesn't exist:{0}", fileName), "fileName"); | 38 | throw new ArgumentException(String.Format(@"File doesn't exist:{0}", fileName), "fileName"); |
| 39 | } | ||
| 36 | 40 | ||
| 37 | logFile = fileName; | 41 | this.logFile = fileName; |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | /// <summary> | 44 | /// <summary> |
| @@ -55,8 +59,8 @@ namespace WixTestTools | |||
| 55 | /// <returns>True if a match is found, False otherwise.</returns> | 59 | /// <returns>True if a match is found, False otherwise.</returns> |
| 56 | public bool LineByLine(Regex regex) | 60 | public bool LineByLine(Regex regex) |
| 57 | { | 61 | { |
| 58 | string line = string.Empty; | 62 | string line; |
| 59 | StreamReader sr = new StreamReader(logFile); | 63 | StreamReader sr = new StreamReader(this.logFile); |
| 60 | 64 | ||
| 61 | // Read from a file stream line by line. | 65 | // Read from a file stream line by line. |
| 62 | while ((line = sr.ReadLine()) != null) | 66 | while ((line = sr.ReadLine()) != null) |
| @@ -82,7 +86,7 @@ namespace WixTestTools | |||
| 82 | /// <returns>True if a match is found, False otherwise.</returns> | 86 | /// <returns>True if a match is found, False otherwise.</returns> |
| 83 | public bool LineByLine(string regex) | 87 | public bool LineByLine(string regex) |
| 84 | { | 88 | { |
| 85 | return LineByLine(new Regex(regex)); | 89 | return this.LineByLine(new Regex(regex)); |
| 86 | } | 90 | } |
| 87 | 91 | ||
| 88 | 92 | ||
| @@ -115,7 +119,7 @@ namespace WixTestTools | |||
| 115 | /// <returns>The number of matches</returns> | 119 | /// <returns>The number of matches</returns> |
| 116 | public int EntireFileAtOnce(string regex) | 120 | public int EntireFileAtOnce(string regex) |
| 117 | { | 121 | { |
| 118 | return EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline)); | 122 | return this.EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline)); |
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | /// <summary> | 125 | /// <summary> |
| @@ -127,9 +131,13 @@ namespace WixTestTools | |||
| 127 | public int EntireFileAtOnce(string regex, bool ignoreCase) | 131 | public int EntireFileAtOnce(string regex, bool ignoreCase) |
| 128 | { | 132 | { |
| 129 | if (!ignoreCase) | 133 | if (!ignoreCase) |
| 130 | return EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline)); | 134 | { |
| 135 | return this.EntireFileAtOnce(new Regex(regex, RegexOptions.Multiline)); | ||
| 136 | } | ||
| 131 | else | 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 | } | ||
| 133 | } | 141 | } |
| 134 | 142 | ||
| 135 | /// <summary> | 143 | /// <summary> |
| @@ -139,7 +147,7 @@ namespace WixTestTools | |||
| 139 | /// <param name="ignoreCase">Perform case insensitive match</param> | 147 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 140 | public void AssertTextInLog(string regex, bool ignoreCase) | 148 | public void AssertTextInLog(string regex, bool ignoreCase) |
| 141 | { | 149 | { |
| 142 | Assert.True(EntireFileAtOncestr(regex), | 150 | Assert.True(this.EntireFileAtOncestr(regex), |
| 143 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex)); | 151 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex)); |
| 144 | } | 152 | } |
| 145 | 153 | ||
| @@ -150,7 +158,7 @@ namespace WixTestTools | |||
| 150 | /// <param name="ignoreCase">Perform case insensitive match</param> | 158 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 151 | public void AssertTextInLog(Regex regex, bool ignoreCase) | 159 | public void AssertTextInLog(Regex regex, bool ignoreCase) |
| 152 | { | 160 | { |
| 153 | Assert.True(EntireFileAtOnce(regex) >= 1, | 161 | Assert.True(this.EntireFileAtOnce(regex) >= 1, |
| 154 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex.ToString())); | 162 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex.ToString())); |
| 155 | } | 163 | } |
| 156 | 164 | ||
| @@ -161,7 +169,7 @@ namespace WixTestTools | |||
| 161 | /// <param name="ignoreCase">Perform case insensitive match</param> | 169 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 162 | public void AssertTextInLog(string regex) | 170 | public void AssertTextInLog(string regex) |
| 163 | { | 171 | { |
| 164 | AssertTextInLog(regex, true); | 172 | this.AssertTextInLog(regex, true); |
| 165 | } | 173 | } |
| 166 | 174 | ||
| 167 | /// <summary> | 175 | /// <summary> |
| @@ -171,7 +179,7 @@ namespace WixTestTools | |||
| 171 | /// <param name="ignoreCase">Perform case insensitive match</param> | 179 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 172 | public void AssertTextInLog(Regex regex) | 180 | public void AssertTextInLog(Regex regex) |
| 173 | { | 181 | { |
| 174 | AssertTextInLog(regex, true); | 182 | this.AssertTextInLog(regex, true); |
| 175 | } | 183 | } |
| 176 | 184 | ||
| 177 | 185 | ||
| @@ -182,7 +190,7 @@ namespace WixTestTools | |||
| 182 | /// <param name="ignoreCase">Perform case insensitive match</param> | 190 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 183 | public void AssertTextNotInLog(Regex regex, bool ignoreCase) | 191 | public void AssertTextNotInLog(Regex regex, bool ignoreCase) |
| 184 | { | 192 | { |
| 185 | Assert.True(EntireFileAtOnce(regex) < 1, | 193 | Assert.True(this.EntireFileAtOnce(regex) < 1, |
| 186 | String.Format("The log contain a match to the regular expression \"{0}\" ", regex.ToString())); | 194 | String.Format("The log contain a match to the regular expression \"{0}\" ", regex.ToString())); |
| 187 | } | 195 | } |
| 188 | 196 | ||
| @@ -193,7 +201,7 @@ namespace WixTestTools | |||
| 193 | /// <param name="ignoreCase">Perform case insensitive match</param> | 201 | /// <param name="ignoreCase">Perform case insensitive match</param> |
| 194 | public void AssertTextNotInLog(string regex, bool ignoreCase) | 202 | public void AssertTextNotInLog(string regex, bool ignoreCase) |
| 195 | { | 203 | { |
| 196 | Assert.False(EntireFileAtOncestr(regex), | 204 | Assert.False(this.EntireFileAtOncestr(regex), |
| 197 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex)); | 205 | String.Format("The log does not contain a match to the regular expression \"{0}\" ", regex)); |
| 198 | } | 206 | } |
| 199 | 207 | ||
