-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Something that I really like about the ShouldRenderFile and ShouldReturnContent methods is that they ultimately return the ActionResult.
Making the ActionResult instance available enables the consumer to write coarse-grained tests against the result whilst still reaping the benefits of the library:
var sut = new HomeController();
string actual = sut.WithCallTo(c => c.Index())
.ShouldReturnContent().Content;
StringAssert.Contains(actual, "foo");I know that certain test methods need to return an interim instance to support the fluent interface - ShouldRenderDefaultView returns ViewResultTest for example - but other methods - such as ShouldReturnJson - currently return void when they could return an ActionResult.
To given an example - If we made ShouldReturnJson return the JsonResult we could enable coarse-grained tests like this one:
var sut = new HomeController();
var actual = sut.WithCallTo(c => c.Index())
.ShouldReturnJson();
Assert.AreEqual(JsonRequestBehavior.AllowGet, actual.JsonRequestBehavior);What do you think?
I see this as being relevant for the following select test methods as of right now:
ShouldGiveHttpStatusShouldReturnEmptyResultShouldRenderJson
Do you see any other opportunities?