|
3 | 3 | using System.Linq.Expressions;
|
4 | 4 | using System.Net;
|
5 | 5 | using System.Reflection;
|
6 |
| -using System.Runtime.InteropServices; |
7 | 6 | using System.Text;
|
8 | 7 | using System.Text.RegularExpressions;
|
9 | 8 | using System.Web.Mvc;
|
10 | 9 | using System.Web.Routing;
|
11 |
| -using System.Web.UI.WebControls; |
12 | 10 |
|
13 | 11 | namespace TestStack.FluentMVCTesting
|
14 | 12 | {
|
@@ -216,27 +214,6 @@ public ViewResultTest ShouldRenderDefaultPartialView()
|
216 | 214 |
|
217 | 215 | #endregion
|
218 | 216 |
|
219 |
| - public FileContentResult ShouldRenderFileContents(string contents, string contentType = null, Encoding encoding = null) |
220 |
| - { |
221 |
| - ValidateActionReturnType<FileContentResult>(); |
222 |
| - |
223 |
| - var fileResult = (FileContentResult) _actionResult; |
224 |
| - |
225 |
| - if (contentType != null && fileResult.ContentType != contentType) |
226 |
| - { |
227 |
| - throw new ActionResultAssertionException(string.Format("Expected file to be of content type '{0}', but instead was given '{1}'.", contentType, fileResult.ContentType)); |
228 |
| - } |
229 |
| - |
230 |
| - if (encoding == null) encoding = Encoding.UTF8; |
231 |
| - var reconstitutedText = encoding.GetString(fileResult.FileContents); |
232 |
| - if (contents != reconstitutedText) |
233 |
| - { |
234 |
| - throw new ActionResultAssertionException(string.Format("Expected file contents to be \"{0}\", but instead was \"{1}\".", contents, reconstitutedText)); |
235 |
| - } |
236 |
| - |
237 |
| - return fileResult; |
238 |
| - } |
239 |
| - |
240 | 217 | #region File Results
|
241 | 218 |
|
242 | 219 | public FileResult ShouldRenderAnyFile(string contentType = null)
|
@@ -275,6 +252,31 @@ public FileContentResult ShouldRenderFileContents(byte[] contents = null, string
|
275 | 252 | return fileResult;
|
276 | 253 | }
|
277 | 254 |
|
| 255 | + public FileContentResult ShouldRenderFileContents(string contents, string contentType = null, Encoding encoding = null) |
| 256 | + { |
| 257 | + ValidateActionReturnType<FileContentResult>(); |
| 258 | + |
| 259 | + var fileResult = (FileContentResult)_actionResult; |
| 260 | + |
| 261 | + if (contentType != null && fileResult.ContentType != contentType) |
| 262 | + { |
| 263 | + throw new ActionResultAssertionException( |
| 264 | + string.Format("Expected file to be of content type '{0}', but instead was given '{1}'.", contentType, |
| 265 | + fileResult.ContentType)); |
| 266 | + } |
| 267 | + |
| 268 | + if (encoding == null) |
| 269 | + encoding = Encoding.UTF8; |
| 270 | + |
| 271 | + var reconstitutedText = encoding.GetString(fileResult.FileContents); |
| 272 | + if (contents != reconstitutedText) |
| 273 | + { |
| 274 | + throw new ActionResultAssertionException(string.Format("Expected file contents to be \"{0}\", but instead was \"{1}\".", contents, reconstitutedText)); |
| 275 | + } |
| 276 | + |
| 277 | + return fileResult; |
| 278 | + } |
| 279 | + |
278 | 280 | [Obsolete("Obsolete: Use ShouldRenderFileContents instead.")]
|
279 | 281 | public FileContentResult ShouldRenderFile(string contentType = null)
|
280 | 282 | {
|
|
0 commit comments