{"__v":7,"_id":"54cfc714bba1a023008741f1","category":{"__v":2,"_id":"54cfb737bba1a023008741a2","pages":["54cfb737bba1a023008741a4","54cfba45bba1a023008741bd"],"project":"54cfb736bba1a0230087419e","version":"54cfb736bba1a023008741a1","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-02T17:43:19.055Z","from_sync":false,"order":0,"slug":"introduction","title":"Introduction"},"project":"54cfb736bba1a0230087419e","user":"54c4ca54686bce0d00efe1b9","version":{"__v":5,"_id":"54cfb736bba1a023008741a1","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-02T18:51:00.086Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"This page demonstrates the basics for using FluentMvcTesting to get you up and running quickly. It assumes you have read and followed the [installation guide](doc:installation) \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Unit testing\"\n}\n[/block]\nThe following code snippet is an example for how to set up a test class to use FluentMVCTesting using NUnit. **Note:** you can use any test framework - NUnit is purely used as an example.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"using MyApp.Controllers;\\nusing NUnit.Framework;\\nusing TestStack.FluentMVCTesting;\\n\\nnamespace MyApp.Tests.Controllers\\n{\\n    [TestFixture]\\n    public class HomeControllerShould\\n    {\\n        private HomeController _controller;\\n\\n        [SetUp]\\n        public void Setup()\\n        {\\n            _controller = new HomeController();\\n        }\\n\\n        [Test]\\n        public void Render_default_view_for_get_to_index()\\n        {\\n            _controller.WithCallTo(c => c.Index())\\n                .ShouldRenderDefaultView();\\n        }\\n    }\\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nThis checks that when `_controller.Index()` is called then the `ActionResult` that is returned is of type `ViewResult` and that the view name returned is either \"Index\" or \"\" (the default view for the `Index` action); easy huh?\n\nFrom here we recommend you check out the [Examples](doc:examples) for a broad idea of the types of things FluentMvcTesting can do. Then dive into the Usage section for a more complete picture.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Subcutaneous testing\"\n}\n[/block]\nFor an example of how we use FluentMvcTesting for writing BDD-style subcutaneous tests please [see Rob's blog post](http://robdmoore.id.au/blog/2015/01/26/review-of-jimmy-bogard-holistic-testing/).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"General syntax structure\"\n}\n[/block]\nAs you might have gathered from the above code snippet, the entry point to the library is the `WithCallTo` extension method on the MVC Controller class (or alternatively the [`WithCallToChild`](doc:child-actions) extension method). Inside of that method call you simply pass in a lambda expression indicates the action call you are trying to test. From there you can use intellisense to guide the rest (or check out our Usage section)!","excerpt":"","slug":"usage","type":"basic","title":"Getting started"}
This page demonstrates the basics for using FluentMvcTesting to get you up and running quickly. It assumes you have read and followed the [installation guide](doc:installation) [block:api-header] { "type": "basic", "title": "Unit testing" } [/block] The following code snippet is an example for how to set up a test class to use FluentMVCTesting using NUnit. **Note:** you can use any test framework - NUnit is purely used as an example. [block:code] { "codes": [ { "code": "using MyApp.Controllers;\nusing NUnit.Framework;\nusing TestStack.FluentMVCTesting;\n\nnamespace MyApp.Tests.Controllers\n{\n [TestFixture]\n public class HomeControllerShould\n {\n private HomeController _controller;\n\n [SetUp]\n public void Setup()\n {\n _controller = new HomeController();\n }\n\n [Test]\n public void Render_default_view_for_get_to_index()\n {\n _controller.WithCallTo(c => c.Index())\n .ShouldRenderDefaultView();\n }\n }\n}", "language": "csharp" } ] } [/block] This checks that when `_controller.Index()` is called then the `ActionResult` that is returned is of type `ViewResult` and that the view name returned is either "Index" or "" (the default view for the `Index` action); easy huh? From here we recommend you check out the [Examples](doc:examples) for a broad idea of the types of things FluentMvcTesting can do. Then dive into the Usage section for a more complete picture. [block:api-header] { "type": "basic", "title": "Subcutaneous testing" } [/block] For an example of how we use FluentMvcTesting for writing BDD-style subcutaneous tests please [see Rob's blog post](http://robdmoore.id.au/blog/2015/01/26/review-of-jimmy-bogard-holistic-testing/). [block:api-header] { "type": "basic", "title": "General syntax structure" } [/block] As you might have gathered from the above code snippet, the entry point to the library is the `WithCallTo` extension method on the MVC Controller class (or alternatively the [`WithCallToChild`](doc:child-actions) extension method). Inside of that method call you simply pass in a lambda expression indicates the action call you are trying to test. From there you can use intellisense to guide the rest (or check out our Usage section)!