{"_id":"54cfceef3995cf0d0006f736","version":{"_id":"54cfb736bba1a023008741a1","__v":5,"project":"54cfb736bba1a0230087419e","createdAt":"2015-02-02T17:43:18.560Z","releaseDate":"2015-02-02T17:43:18.560Z","categories":["54cfb737bba1a023008741a2","54cfc6f75ff7e617002bbdae","54cfcbaebba1a023008741fc","54cfd0295ff7e617002bbdd9","54cfd05b3995cf0d0006f741"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"54cfc6f75ff7e617002bbdae","__v":11,"project":"54cfb736bba1a0230087419e","pages":["54cfc714bba1a023008741f1","54cfcc24bba1a02300874200","54cfcc545ff7e617002bbdbe","54cfccf73995cf0d0006f729","54cfce14bba1a02300874205","54cfce42bba1a02300874209","54cfceef3995cf0d0006f736","54cfcf7dbba1a02300874218","54cfcfae3995cf0d0006f73b","54cfcfc4bba1a0230087421b","54cfcfdc3995cf0d0006f73d"],"version":"54cfb736bba1a023008741a1","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-02T18:50:31.446Z","from_sync":false,"order":2,"slug":"usage","title":"Usage"},"user":"54c4ca54686bce0d00efe1b9","project":"54cfb736bba1a0230087419e","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-02T19:24:31.812Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_controller.WithCallTo(c => c.Index()).ShouldRenderAnyFile();\\n_controller.WithCallTo(c => c.Index()).ShouldRenderAnyFile(\\\"content/type\\\");\\n\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents();\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(new byte[] {1});\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(new byte[] {1}, \\\"content/type\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\\\"text\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\\\"text\\\", \\\"content/type\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\\\"text\\\", \\\"content/type\\\", Encoding.Unicode);\\n\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream();\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new byte[] {1});\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new byte[] {1}, \\\"content/type\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new MemoryStream());\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new MemoryStream(), \\\"content/type\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\\\"text\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\\\"text\\\", \\\"content/type\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\\\"text\\\", \\\"content/type\\\", Encoding.Unicode);\\n\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath();\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath(\\\"file name\\\");\\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath(\\\"file name\\\", \\\"content/type\\\");\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nIt is useful to note that whilst file content is ultimately represented in memory as binary data, we enable you to test for textual content using convenience overloads.\n\nIn order achieve this - internally we reconstitute the text by assuming that the file content is UTF8 encoded. If you know our assumption to be wrong then you must explicitly tell the test method the actual file content encoding by means of the apparent `encoding` argument as not to cause a misleading test failure.","excerpt":"","slug":"files","type":"basic","title":"Files"}
[block:code] { "codes": [ { "code": "_controller.WithCallTo(c => c.Index()).ShouldRenderAnyFile();\n_controller.WithCallTo(c => c.Index()).ShouldRenderAnyFile(\"content/type\");\n\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents();\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(new byte[] {1});\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(new byte[] {1}, \"content/type\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\"text\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\"text\", \"content/type\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileContents(\"text\", \"content/type\", Encoding.Unicode);\n\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream();\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new byte[] {1});\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new byte[] {1}, \"content/type\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new MemoryStream());\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(new MemoryStream(), \"content/type\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\"text\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\"text\", \"content/type\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFileStream(\"text\", \"content/type\", Encoding.Unicode);\n\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath();\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath(\"file name\");\n_controller.WithCallTo(c => c.Index()).ShouldRenderFilePath(\"file name\", \"content/type\");", "language": "csharp" } ] } [/block] It is useful to note that whilst file content is ultimately represented in memory as binary data, we enable you to test for textual content using convenience overloads. In order achieve this - internally we reconstitute the text by assuming that the file content is UTF8 encoded. If you know our assumption to be wrong then you must explicitly tell the test method the actual file content encoding by means of the apparent `encoding` argument as not to cause a misleading test failure.