Skip to content

Commit 0f0dd57

Browse files
committed
Added support for checking for a file path results' content type.
Partial implementation of #3.
1 parent 3ad50c9 commit 0f0dd57

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

TestStack.FluentMVCTesting.Tests/ControllerResultTestTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ public void Check_for_file_path_result_and_check_file_name()
337337
_controller.WithCallTo(c => c.EmptyFilePath()).ShouldRenderFilePath(ControllerResultTestController.FileName);
338338
}
339339

340+
[Test]
341+
public void Check_for_file_path_result_and_check_file_name_and_check_content_type()
342+
{
343+
_controller.WithCallTo(c => c.EmptyFilePath()).ShouldRenderFilePath(ControllerResultTestController.FileName, ControllerResultTestController.FileContentType);
344+
}
345+
340346
#endregion
341347

342348
#region HTTP Status tests

TestStack.FluentMvcTesting/ControllerResultTest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public FileStreamResult ShouldRenderFileStream(string contentType = null)
238238
return fileResult;
239239
}
240240

241-
public FilePathResult ShouldRenderFilePath(string fileName = null)
241+
public FilePathResult ShouldRenderFilePath(string fileName = null, string contentType = null)
242242
{
243243
ValidateActionReturnType<FilePathResult>();
244244

@@ -249,6 +249,11 @@ public FilePathResult ShouldRenderFilePath(string fileName = null)
249249
throw new ActionResultAssertionException(string.Format("Expected file name to be '{0}', but instead was given '{1}'.", fileName, fileResult.FileName));
250250
}
251251

252+
if (contentType != null && fileResult.ContentType != contentType)
253+
{
254+
throw new ActionResultAssertionException(string.Format("Expected file to be of content type '{0}', but instead was given '{1}'.", contentType, fileResult.ContentType));
255+
}
256+
252257
return fileResult;
253258
}
254259

0 commit comments

Comments
 (0)