private static HttpContextBase FakeHttpContext(string url, HttpVerbs?httpMethod, HttpVerbs?formMethod)
        {
            NameValueCollection form = null;

            if (formMethod.HasValue)
            {
                form = new NameValueCollection {
                    { "_method", formMethod.Value.ToString().ToUpper() }
                }
            }
            ;

            if (!httpMethod.HasValue)
            {
                httpMethod = HttpVerbs.Get;
            }

            var mockFactory = new FirstAvailableMockFactory();
            var request     = mockFactory.DynamicMock <HttpRequestBase>();

            request.ReturnFor(x => x.AppRelativeCurrentExecutionFilePath, url);
            request.ReturnFor(x => x.PathInfo, string.Empty);
            request.ReturnFor(x => x.Form, form);
            request.ReturnFor(x => x.HttpMethod, httpMethod.Value.ToString().ToUpper());

            var context = new FakeHttpContext(url);

            context.SetRequest(request.Object);

            return(context);
        }
        private static HttpContextBase FakeHttpContext(string url, HttpVerbs?httpMethod, HttpVerbs?formMethod)
        {
            NameValueCollection form = null;

            if (formMethod.HasValue)
            {
                form = new NameValueCollection {
                    { "_method", formMethod.Value.ToString().ToUpper() }
                }
            }
            ;

            if (!httpMethod.HasValue)
            {
                httpMethod = HttpVerbs.Get;
            }

            var mockFactory = new FirstAvailableMockFactory();
            var request     = mockFactory.DynamicMock <HttpRequestBase>();

            request.ReturnFor(x => x.AppRelativeCurrentExecutionFilePath, url);
            request.ReturnFor(x => x.PathInfo, string.Empty);
            request.ReturnFor(x => x.Form, form);
            request.ReturnFor(x => x.HttpMethod, httpMethod.Value.ToString().ToUpper());

            if (url.StartsWith("/"))
            {
                url = url.Insert(0, "http://www.google.com");
            }
            else if (url.StartsWith("~"))
            {
                url = url.Substring(1, url.Length - 1);
                url = url.Insert(0, "http://www.google.com");
            }

            var uri        = new System.Uri(url);
            var parameters = HttpUtility.ParseQueryString(uri.Query);

            request.ReturnFor(x => x.Params, parameters);
            request.ReturnFor(x => x.Path, uri.AbsolutePath);

            var context = new FakeHttpContext(url);

            context.SetRequest(request.Object);

            return(context);
        }
        public void Should_Fallback_To_Next_Available_Framework_If_Error_Occurs()
        {
            var factory = new FirstAvailableMockFactory(typeof(BadFactory), typeof(MoqFactory));

            factory.DynamicMock <IController>().GetType().ShouldEqual(typeof(MoqProxy <IController>));
        }
        public void Should_Default_To_RhinoMocks()
        {
            var factory = new FirstAvailableMockFactory();

            factory.DynamicMock <IController>().GetType().ShouldEqual(typeof(RhinoMocksProxy <IController>));
        }