src/MvcContrib.TestHelper/MvcContrib.TestHelper/FluentController/ActionExpectations.cs
/// <summary>
/// Creates the setup conditions for a <see cref="GivenController"/>.As with the <see cref="RequestContext"/> to allow for mocking on the object.
/// This is the full version and there are shorter wrapper for specific headers <see cref="WithLocation"/>, <see cref="WithReferrer"/> and <see cref="WithUserAgent"/>.
/// <example>
/// <code>
///     GivenController.As&lt;UserController>()
///         .Should(x => x.AssertResultIs&lt;HeadResult>().StatusCode.ShouldBe(HttpStatusCode.OK))
///         .WhenCalling(x => x.Show());
/// </code>
/// </example>
/// </summary>
/// <param name="setupAction">The setup action.</param>
/// <returns></returns>
Creates the setup conditions for a .As with the  to allow for mocking on the object.
This is the full version and there are shorter wrapper for specific headers ,  and .


Creates the setup conditions for a . As with the to allow for mocking on the object . This is the full version and there are shorter wrapper for specific headers and .
public ActionExpectations<T> WithRequest(Action<HttpRequestBase> setupAction)
		{
			if(setupAction != null)
			{
				if(MockRequest == null)
				{
					var fakeHttpContext = FakeHttpContext.Root();
					MockRequest = MockRepository.GenerateMock<HttpRequestBase>();
					var mockResponse = MockRepository.GenerateMock<HttpResponseBase>();
					fakeHttpContext.SetResponse(mockResponse);
					fakeHttpContext.SetRequest(MockRequest);
					MockController.ControllerContext = new ControllerContext(new RequestContext(fakeHttpContext, new RouteData()),
					                                                         MockController);
				}
				setupAction(MockRequest);
			}
			return this;
		}
public ActionExpectations < T > WithRequest ( Action < HttpRequestBase > setupAction ) { if ( setupAction != null ) { if ( MockRequest == null ) { var fakeHttpContext = FakeHttpContext . Root ( ) ; MockRequest = MockRepository . GenerateMock < HttpRequestBase > ( ) ; var mockResponse = MockRepository . GenerateMock < HttpResponseBase > ( ) ; fakeHttpContext . SetResponse ( mockResponse ) ; fakeHttpContext . SetRequest ( MockRequest ) ; MockController . ControllerContext = new ControllerContext ( new RequestContext ( fakeHttpContext , new RouteData ( ) ) , MockController ) ; } setupAction ( MockRequest ) ; } return this ; }
Creates the setup conditions for a .As with the  to allow for mocking on the object.
Creates the setup conditions for a . As with the to allow for mocking on the object .
None
setupAction
Action<HttpRequestBase>
The setup action.
The setup action .