|
7 | 7 | using System.Web.Mvc; |
8 | 8 | using NUnit.Framework; |
9 | 9 | using TestStack.FluentMVCTesting.Tests.TestControllers; |
| 10 | +using System.Text; |
| 11 | + |
10 | 12 |
|
11 | 13 | namespace TestStack.FluentMVCTesting.Tests |
12 | 14 | { |
@@ -34,6 +36,7 @@ class ControllerResultTestShould |
34 | 36 | ReturnType<FileContentResult>(t => t.ShouldRenderFileContents(new byte[0], "")), |
35 | 37 | ReturnType<FileContentResult>(t => t.ShouldRenderFileContents("")), |
36 | 38 | ReturnType<FileContentResult>(t => t.ShouldRenderFileContents("", "")), |
| 39 | + ReturnType<FileContentResult>(t => t.ShouldRenderFileContents("", "", Encoding.UTF8)), |
37 | 40 | ReturnType<FileStreamResult>(t => t.ShouldRenderFileStream("")), |
38 | 41 | ReturnType<FilePathResult>(t => t.ShouldRenderFilePath()), |
39 | 42 | ReturnType<FilePathResult>(t => t.ShouldRenderFilePath("")), |
@@ -313,7 +316,9 @@ public void Check_for_invalid_partial_name() |
313 | 316 | Assert.That(exception.Message, Is.EqualTo(string.Format("Expected result view to be '{0}', but instead was given '{1}'.", ControllerResultTestController.PartialName, ControllerResultTestController.RandomViewName))); |
314 | 317 | } |
315 | 318 | #endregion |
316 | | - |
| 319 | + |
| 320 | + |
| 321 | + |
317 | 322 | #region File tests |
318 | 323 |
|
319 | 324 | [Test] |
@@ -445,6 +450,32 @@ public void Check_for_file_content_result_and_check_invalid_textual_content_and_ |
445 | 450 | Assert.That(exception.Message.Contains("content type")); |
446 | 451 | } |
447 | 452 |
|
| 453 | + [Test] |
| 454 | + public void Check_for_file_content_result_and_check_textual_content_using_given_char_encoding() |
| 455 | + { |
| 456 | + var encoding = Encoding.BigEndianUnicode; |
| 457 | + |
| 458 | + _controller.WithCallTo(c => c.TextualFile(encoding)) |
| 459 | + .ShouldRenderFileContents(ControllerResultTestController.TextualFileContents, encoding: encoding); |
| 460 | + } |
| 461 | + |
| 462 | + [Test] |
| 463 | + public void Check_for_file_content_result_and_check_textual_content_using_given_char_encoding_and_check_content_type() |
| 464 | + { |
| 465 | + var encoding = Encoding.BigEndianUnicode; |
| 466 | + |
| 467 | + _controller.WithCallTo(c => c.TextualFile(encoding)).ShouldRenderFileContents(ControllerResultTestController.TextualFileContents, ControllerResultTestController.FileContentType, encoding); |
| 468 | + } |
| 469 | + |
| 470 | + [Test] |
| 471 | + public void Check_for_file_content_result_and_check_textual_content_using_invalid_given_char_encoding() |
| 472 | + { |
| 473 | + Assert.Throws<ActionResultAssertionException>(() => |
| 474 | + _controller.WithCallTo(c => c.TextualFile()) |
| 475 | + .ShouldRenderFileContents(ControllerResultTestController.TextualFileContents, |
| 476 | + ControllerResultTestController.FileContentType, Encoding.BigEndianUnicode)); |
| 477 | + } |
| 478 | + |
448 | 479 | [Test] |
449 | 480 | public void Check_for_file_result() |
450 | 481 | { |
|
0 commit comments