Skip to content

Commit 907b1eb

Browse files
committed
Added support for checking for a file content result.
Partial implementation of #3.
1 parent 9154051 commit 907b1eb

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

TestStack.FluentMVCTesting.Tests/ControllerResultTestTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ControllerResultTestShould
2727
ReturnType<FileContentResult>(t => t.ShouldRenderFile()),
2828
ReturnType<FileContentResult>(t => t.ShouldRenderFile("")),
2929
ReturnType<FileStreamResult>(t => t.ShouldRenderFileStream()),
30+
ReturnType<FileContentResult>(t => t.ShouldRenderFileContents()),
3031
ReturnType<FileStreamResult>(t => t.ShouldRenderFileStream("")),
3132
ReturnType<FilePathResult>(t => t.ShouldRenderFilePath()),
3233
ReturnType<FilePathResult>(t => t.ShouldRenderFilePath("")),
@@ -336,6 +337,12 @@ public void Check_for_any_file_result_and_check_invalid_content_type()
336337
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected file to be of content type '{0}', but instead was given '{1}'.", contentType, ControllerResultTestController.FileContentType)));
337338
}
338339

340+
[Test]
341+
public void Check_for_file_content_result()
342+
{
343+
_controller.WithCallTo(c => c.EmptyFile()).ShouldRenderFileContents();
344+
}
345+
339346
[Test]
340347
public void Check_for_file_result()
341348
{

TestStack.FluentMVCTesting.Tests/TestControllers/ControllerResultTestController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ public ActionResult EmptyFile()
159159
return File(content, FileContentType);
160160
}
161161

162+
public ActionResult File()
163+
{
164+
return EmptyFile();
165+
}
166+
162167
public ActionResult EmptyStream()
163168
{
164169
var content = new MemoryStream();

TestStack.FluentMvcTesting/ControllerResultTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq.Expressions;
33
using System.Net;
44
using System.Reflection;
5+
using System.Runtime.InteropServices;
56
using System.Text.RegularExpressions;
67
using System.Web.Mvc;
78
using System.Web.Routing;
@@ -228,6 +229,12 @@ public FileResult ShouldRenderAnyFile(string contentType = null)
228229
return fileResult;
229230
}
230231

232+
public FileContentResult ShouldRenderFileContents()
233+
{
234+
ValidateActionReturnType<FileContentResult>();
235+
return (FileContentResult) _actionResult;
236+
}
237+
231238
public FileContentResult ShouldRenderFile(string contentType = null)
232239
{
233240
ValidateActionReturnType<FileContentResult>();

0 commit comments

Comments
 (0)