@@ -43,34 +43,34 @@ Make sure to check out [the documentation](http://docs.teststack.net/fluentmvcte
4343Say you set up the following test class (this example with NUnit, but it will work for any test framework).
4444
4545``` c#
46- using MyApp .Controllers ;
47- using NUnit .Framework ;
48- using TestStack .FluentMVCTesting ;
49-
50- namespace MyApp .Tests .Controllers
46+ using MyApp .Controllers ;
47+ using NUnit .Framework ;
48+ using TestStack .FluentMVCTesting ;
49+
50+ namespace MyApp .Tests .Controllers
51+ {
52+ [TestFixture ]
53+ class HomeControllerShould
5154 {
52- [TestFixture ]
53- class HomeControllerShould
54- {
55- private HomeController _controller ;
55+ private HomeController _controller ;
5656
57- [SetUp ]
58- public void Setup ()
59- {
60- _controller = new HomeController ();
61- }
57+ [SetUp ]
58+ public void Setup ()
59+ {
60+ _controller = new HomeController ();
6261 }
6362 }
63+ }
6464```
6565
6666Then you can create a test like this:
6767
6868``` c#
69- [Test ]
70- public void Render_default_view_for_get_to_index ()
71- {
72- _controller .WithCallTo (c => c .Index ()).ShouldRenderDefaultView ();
73- }
69+ [Test ]
70+ public void Render_default_view_for_get_to_index ()
71+ {
72+ _controller .WithCallTo (c => c .Index ()).ShouldRenderDefaultView ();
73+ }
7474```
7575
7676This 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?
@@ -105,16 +105,21 @@ _controller.WithCallTo(c => c.Index())
105105 .ShouldRedirectTo <SomeOtherController >(c => c .SomeAction ());
106106
107107_controller .WithCallTo (c => c .Index ())
108- .ShouldRenderFile (" text/plain" );
108+ .ShouldRenderAnyFile (" content/type" );
109+
110+ _controller .WithCallTo (c => c .Index ())
111+ .ShouldRenderFileContents (" text" );
112+
113+ _controller .WithCallTo (c => c .Index ())
114+ .ShouldReturnContent (" expected content" );
109115
110116_controller .WithCallTo (c => c .Index ())
111117 .ShouldGiveHttpStatus (404 );
112118
113119_controller .WithCallTo (c => c .Index ()).ShouldReturnJson (data =>
114- {
115- Assert .That (data .SomeProperty , Is .EqualTo (" SomeValue" );
116- }
117- );
120+ {
121+ Assert .That (data .SomeProperty , Is .EqualTo (" SomeValue" );
122+ });
118123```
119124
120125Any questions , comments or additions ?
0 commit comments