Skip to content

Commit 8e7818d

Browse files
committed
Merge pull request #34 from ByteBlast/readme
Readme
2 parents 4f991ac + 5e07e0a commit 8e7818d

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

README.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,34 @@ Make sure to check out [the documentation](http://docs.teststack.net/fluentmvcte
4343
Say 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

6666
Then 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

7676
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?
@@ -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

120125
Any questions, comments or additions?

0 commit comments

Comments
 (0)