Skip to content

Commit fddfd5f

Browse files
committed
Removed ShouldRenderFile and documented breaking change.
1 parent 3ffd3c0 commit fddfd5f

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

BREAKING_CHANGES.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,27 @@ Use a [named argument](http://msdn.microsoft.com/en-gb/library/dd264739.aspx).
1818

1919
As where you would have previously done this:
2020

21-
.ShouldRenderFileStream("application/json");
21+
ShouldRenderFileStream("application/json");
2222

2323
You must now do this:
2424

25-
.ShouldRenderFileStream(contentType: "application/json");
25+
ShouldRenderFileStream(contentType: "application/json");
26+
27+
28+
## ShouldRenderFileMethod
29+
30+
The `ShouldRenderFile` method has been removed.
31+
32+
### Reason
33+
34+
The `ShouldRenderFile` method was equivocal because it had the possibility to be interperted to test for a `FileResult` when in fact, it tested for a `FileContentResult`.
35+
36+
It is for this reason that we introduced two unequivocal methods namely, `ShouldRenderAnyFile` and `ShouldRenderFileContents`.
37+
38+
### Fix
39+
40+
Use the `ShouldRenderFileContents` method instead:
41+
42+
ShouldRenderAnyFile()
43+
ShouldRenderAnyFile(contentType: "application/json")
2644

TestStack.FluentMVCTesting.Tests/ControllerResultTestTests.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class ControllerResultTestShould
2828
ReturnType<ViewResult>(t => t.ShouldRenderDefaultView()),
2929
ReturnType<PartialViewResult>(t => t.ShouldRenderPartialView("")),
3030
ReturnType<PartialViewResult>(t => t.ShouldRenderDefaultPartialView()),
31-
ReturnType<FileContentResult>(t => t.ShouldRenderFile()),
32-
ReturnType<FileContentResult>(t => t.ShouldRenderFile("")),
3331
ReturnType<FileContentResult>(t => t.ShouldRenderFileContents()),
3432
ReturnType<FileContentResult>(t => t.ShouldRenderFileContents(new byte[0])),
3533
ReturnType<FileContentResult>(t => t.ShouldRenderFileContents(new byte[0], "")),
@@ -479,18 +477,6 @@ public void Check_for_file_content_result_and_check_textual_content_using_invali
479477
_controller.WithCallTo(c => c.TextualFile()).ShouldRenderFileContents(ControllerResultTestController.TextualFileContent, ControllerResultTestController.FileContentType, Encoding.BigEndianUnicode));
480478
}
481479

482-
[Test]
483-
public void Check_for_file_result()
484-
{
485-
_controller.WithCallTo(c => c.EmptyFile()).ShouldRenderFile();
486-
}
487-
488-
[Test]
489-
public void Check_for_file_result_and_check_content_type()
490-
{
491-
_controller.WithCallTo(c => c.EmptyFile()).ShouldRenderFile(ControllerResultTestController.FileContentType);
492-
}
493-
494480
[Test]
495481
public void Check_for_file_stream_result()
496482
{

TestStack.FluentMvcTesting/ControllerResultTest.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,21 +278,6 @@ public FileContentResult ShouldRenderFileContents(string contents, string conten
278278
return fileResult;
279279
}
280280

281-
[Obsolete("Obsolete: Use ShouldRenderFileContents instead.")]
282-
public FileContentResult ShouldRenderFile(string contentType = null)
283-
{
284-
ValidateActionReturnType<FileContentResult>();
285-
286-
var fileResult = (FileContentResult)_actionResult;
287-
288-
if (contentType != null && fileResult.ContentType != contentType)
289-
{
290-
throw new ActionResultAssertionException(string.Format("Expected file to be of content type '{0}', but instead was given '{1}'.", contentType, fileResult.ContentType));
291-
}
292-
293-
return fileResult;
294-
}
295-
296281
public FileStreamResult ShouldRenderFileStream(byte[] content, string contentType = null)
297282
{
298283
return ShouldRenderFileStream(new MemoryStream(content), contentType);

0 commit comments

Comments
 (0)