public void map_from_execution_when_the_request_was_redirected() { var log = new ChainExecutionLog(); log.Request.Add(OwinConstants.ResponseStatusCodeKey, 302); log.Request.ResponseHeaders().Add(HttpResponseHeaders.ContentType, new[] { "text/plain" }); log.Request.ResponseHeaders().Add(HttpResponseHeaders.Location, new[] { "/new/place" }); var request = new OwinHttpRequest(log.Request); request.HttpMethod("GET"); request.FullUrl("http://server/foo"); log.MarkFinished(); var summary = new HttpRequestSummary(log); summary.id.ShouldBe(log.Id.ToString()); summary.time.ShouldBe(log.Time.ToHttpDateString()); summary.url.ShouldBe("/foo"); summary.method.ShouldBe("GET"); summary.status.ShouldBe(302); summary.contentType.ShouldBe("text/plain"); summary.duration.ShouldBe(log.ExecutionTime); summary.description.ShouldBe("/new/place"); }
public void SetUp() { registry = new FubuRegistry(x => { x.Actions.IncludeType <TestController>(); }); container = new Container(x => { x.For <ICurrentChain>().Use(new CurrentChain(null, null)); x.For <IHttpRequest>().Use(OwinHttpRequest.ForTesting()); }); FubuMvcPackageFacility.PhysicalRootPath = AppDomain.CurrentDomain.BaseDirectory; routes = FubuApplication.For(registry) .StructureMap(container) .Bootstrap() .Routes .Where(r => !r.As <Route>().Url.StartsWith("_content")) .ToList(); container.Configure(x => x.For <IOutputWriter>().Use(new InMemoryOutputWriter())); }
public Scenario(IScenarioSupport support) { _support = support; _request = OwinHttpRequest.ForTesting(); _request.FullUrl(support.RootUrl); _request.Environment.Add("scenario-support", _support); _request.Accepts("*/*"); support.Get <SecuritySettings>().Reset(); _response = new Lazy <OwinHttpResponse>(() => { var response = _support.Send(_request); if (!_ignoreStatusCode) { validateStatusCode(response); } return(response); }); _bodyText = new Lazy <string>(() => _response.Value.Body.ReadAsText()); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); theHttpRequest.FullUrl("http://server/fubu"); var registry = new FubuRegistry(); registry.Actions.IncludeType <OneController>(); registry.Actions.IncludeType <TwoController>(); registry.Actions.IncludeType <QueryStringTestController>(); registry.Actions.IncludeType <OnlyOneActionController>(); registry.Configure(x => { x.TypeResolver.AddStrategy <UrlModelForwarder>(); }); //registry.Routes.HomeIs<DefaultModel>(); graph = BehaviorGraph.BuildFrom(registry); var resolver = graph.Services.DefaultServiceFor <ITypeResolver>().Value; var urlResolver = new ChainUrlResolver(theHttpRequest); urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver)resolver, graph), urlResolver, new JQueryUrlTemplate(), theHttpRequest); }
public void SetUp() { theRequest = new OwinHttpRequest(); theResponse = new OwinHttpResponse(theRequest.Environment); theMiddleware = new StaticFileMiddleware(null, theFiles, new AssetSettings()); }
public OwinHttpResponse Send(OwinHttpRequest request) { // TODO -- make the wait be configurable? request.RewindData(); _func(request.Environment).Wait(15.Seconds()); return(new OwinHttpResponse(request.Environment)); }
public void no_correction_with_no_querystring() { var request = OwinHttpRequest.ForTesting(); var mimeType = new CurrentMimeType("text/json", theOriginalMimetype); new ConnegSettings().InterpretQuerystring(mimeType, request); mimeType.AcceptTypes.Single().ShouldBe(theOriginalMimetype); }
public void SetUp() { graph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeClassesSuffixedWithController()); var request = OwinHttpRequest.ForTesting().FullUrl("http://server/cool"); var urlResolver = new ChainUrlResolver(request); registry = new UrlRegistry(new ChainResolutionCache(graph), urlResolver, request); }
OwinHttpResponse IScenarioSupport.Send(OwinHttpRequest request) { // TODO -- make the wait be configurable? request.RewindData(); _appFunc.Value(request.Environment).Wait(15.Seconds()); return(new OwinHttpResponse(request.Environment)); }
public void SetUp() { headers = new Dictionary<string, string[]>(); var dict = new Dictionary<string, object>(); dict.Add(OwinConstants.RequestHeadersKey, headers); request = new OwinHttpRequest(dict); }
public void SetUp() { environment = new Dictionary<string, object>(); headers = new Dictionary<string, string[]>(); environment.Add(OwinConstants.RequestHeadersKey, headers); environment.Add(OwinConstants.RequestSchemeKey, "https"); setHeader("Host", "localhost"); request = new OwinHttpRequest(environment); }
public void SetUp() { headers = new Dictionary <string, string[]>(); var dict = new Dictionary <string, object>(); dict.Add(OwinConstants.RequestHeadersKey, headers); request = new OwinHttpRequest(dict); }
public OwinHttpResponse Send(Action <OwinHttpRequest> configuration) { var request = OwinHttpRequest.ForTesting(); request.FullUrl(RootUrl); configuration(request); return(Send(request)); }
public void SetUp() { environment = new Dictionary <string, object>(); headers = new Dictionary <string, string[]>(); environment.Add(OwinConstants.RequestHeadersKey, headers); environment.Add(OwinConstants.RequestSchemeKey, "https"); setHeader("Host", "localhost"); request = new OwinHttpRequest(environment); }
public void correct_to_xml() { var request = OwinHttpRequest.ForTesting(); request.QueryString["Format"] = "XML"; var mimeType = new CurrentMimeType("text/json", theOriginalMimetype); new ConnegSettings().InterpretQuerystring(mimeType, request); mimeType.AcceptTypes.Single().ShouldBe(MimeType.Xml.Value); }
public void SetUp() { var dictionary = new Dictionary <string, object>(); source = new CancellationTokenSource(); theToken = source.Token; dictionary.Add(OwinConstants.CallCancelledKey, theToken); theConnectivity = new OwinHttpRequest(dictionary); }
public void SetUp() { var dictionary = new Dictionary<string,object>(); source = new CancellationTokenSource(); theToken = source.Token; dictionary.Add(OwinConstants.CallCancelledKey, theToken); theConnectivity = new OwinHttpRequest(dictionary); }
public void should_populate_fullurl_from_current_http_request() { var stubCurrentHttpRequest = OwinHttpRequest.ForTesting(); var model = BindingScenario <FullUrlModel> .For(x => { x.BindPropertyWith <CurrentRequestFullUrlPropertyBinder>(f => f.FullUrl); x.Service <IHttpRequest>(stubCurrentHttpRequest); }) .Model; model.FullUrl.ShouldEqual(stubCurrentHttpRequest.FullUrl()); }
public Scenario CreateScenario() { var request = OwinHttpRequest.ForTesting(); request.FullUrl(RootUrl); var securitySettings = _services.GetInstance <SecuritySettings>(); securitySettings.Reset(); var scenario = new Scenario(_runtime.Factory.Get <IUrlRegistry>(), request, Send, securitySettings); return(scenario); }
public void HttpMethodMatchesAny() { var request = new OwinHttpRequest().HttpMethod("POST"); request.HttpMethodMatchesAny("get", "put").ShouldBeFalse(); request.HttpMethodMatchesAny("get").ShouldBeFalse(); request.HttpMethodMatchesAny("head", "PUT").ShouldBeFalse(); request.HttpMethodMatchesAny("POST").ShouldBeTrue(); request.HttpMethodMatchesAny("POST", "get").ShouldBeTrue(); request.HttpMethodMatchesAny("post", "get").ShouldBeTrue(); request.HttpMethodMatchesAny("Post", "get").ShouldBeTrue(); }
public void SetUp() { graph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType <UrlCategoryController1>(); x.Actions.IncludeType <UrlCategoryController2>(); x.Actions.IncludeType <UrlCategoryController3>(); }); var request = OwinHttpRequest.ForTesting().FullUrl("http://server/app"); var urlResolver = new ChainUrlResolver(request); registry = new UrlRegistry(new ChainResolutionCache(graph), urlResolver, request); }
public void bind_by_header() { var headers = OwinHttpRequest.ForTesting(); headers.AppendHeader("Last-Event-ID", "something"); headers.AppendHeader(HttpResponseHeaders.Warning, "oh no!"); var target = BindingScenario <HeaderValueTarget> .For(x => { x.Service <IHttpRequest>(headers); }).Model; target.LastEventId.ShouldBe("something"); target.Warning.ShouldBe("oh no!"); }
public OwinServiceArguments(RouteData routeData, IDictionary<string, object> environment) { var httpRequest = new OwinHttpRequest(environment); var httpContextBase = new OwinHttpContext(environment); With<HttpContextBase>(httpContextBase); With(routeData); With<IHttpRequest>(httpRequest); With<IHttpResponse>(new OwinHttpResponse(environment)); With(new OwinContext(environment)); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); UrlContext.Stub("http://server"); theUrlResolver = new ChainUrlResolver(theHttpRequest); theGraph = BehaviorGraph.BuildFrom(registry => { registry.Actions.IncludeType <ChainUrlResolverEndpoint>(); }); theSimpleChain = theGraph.BehaviorFor <ChainUrlResolverEndpoint>(x => x.get_index()); theChainWithRouteParams = theGraph.BehaviorFor(typeof(ChainUrlParams)); }
public void SetUp() { theRequest = OwinHttpRequest.ForTesting(); writer = new InMemoryOutputWriter(); var container = new Container(x => { x.For<IHttpRequest>().Use(theRequest); x.For<IOutputWriter>().Use(writer); x.For<IFubuRequest>().Use(new InMemoryFubuRequest()); }); context = new MockedFubuRequestContext(container); theFormatter = new XmlFormatter(); }
public void SetUp() { theRequest = OwinHttpRequest.ForTesting(); writer = new InMemoryOutputWriter(); var container = new Container(x => { x.For <IHttpRequest>().Use(theRequest); x.For <IOutputWriter>().Use(writer); x.For <IFubuRequest>().Use(new InMemoryFubuRequest()); }); context = new MockedFubuRequestContext(container); theFormatter = new XmlFormatter(); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); UrlContext.Stub("http://server"); theUrlResolver = new ChainUrlResolver(theHttpRequest); theGraph = BehaviorGraph.BuildFrom(registry => { registry.Actions.IncludeType<ChainUrlResolverEndpoint>(); }); theSimpleChain = theGraph.ChainFor<ChainUrlResolverEndpoint>(x => x.get_index()); theChainWithRouteParams = theGraph.ChainFor(typeof(ChainUrlParams)); }
public void use_a_custom_querystring_parameter() { var request = OwinHttpRequest.ForTesting(); request.QueryString["Format"] = "Text"; var settings = new ConnegSettings(); settings.QuerystringParameters.Add(new ConnegQuerystring("Format", "Text", MimeType.Text)); var mimeType = new CurrentMimeType("text/json", theOriginalMimetype); settings.InterpretQuerystring(mimeType, request); mimeType.AcceptTypes.Single().ShouldBe(MimeType.Text.Value); }
public void can_inject_arguments_into_the_behavior_factory() { var standInCurrentHttpRequest = OwinHttpRequest.ForTesting(); var inMemoryFubuRequest = new InMemoryFubuRequest(); var arguments = new ServiceArguments() .With <IHttpRequest>(standInCurrentHttpRequest) .With <IFubuRequest>(inMemoryFubuRequest); var behavior = ContainerFacilitySource .BuildBehavior(arguments, ObjectDef.ForType <GuyWhoNeedsRequest>(), x => { }) .As <GuyWhoNeedsRequest>(); behavior.Http.ShouldBeTheSameAs(standInCurrentHttpRequest); behavior.Request.ShouldBeTheSameAs(inMemoryFubuRequest); }
public void should_populate_relativeurl_from_current_http_request() { var stubCurrentHttpRequest = OwinHttpRequest.ForTesting().FullUrl("http://server/foo"); var model = BindingScenario <RelativeUrlModel> .For(x => { x.BindPropertyWith <CurrentRequestRelativeUrlPropertyBinder>(f => f.RelativeUrl); x.Service <IHttpRequest>(stubCurrentHttpRequest); }) .Model; model.RelativeUrl.ShouldBe(stubCurrentHttpRequest.RelativeUrl()); }
public string GenerateTextForCurrentThreadCulture() { var request = OwinHttpRequest.ForTesting(); request.ContentType(MimeType.HttpFormMimetype); request.Accepts(MimeType.Html.Value); var services = new OwinServiceArguments(new RouteData(), request.Environment); var invoker = new BehaviorInvoker(_parent._services, _chain); invoker.Invoke(services); var response = new OwinHttpResponse(request.Environment); return(response.Body.ReadAsText()); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); theHttpRequest.FullUrl("http://server/fubu"); var registry = new FubuRegistry(); registry.Actions.IncludeType<OneController>(); registry.Actions.IncludeType<TwoController>(); registry.Actions.IncludeType<QueryStringTestController>(); registry.Actions.IncludeType<OnlyOneActionController>(); graph = BehaviorGraph.BuildFrom(registry); var urlResolver = new ChainUrlResolver(theHttpRequest); urls = new UrlRegistry(new ChainResolutionCache(graph), urlResolver, theHttpRequest); }
public void SetUp() { var advanced = MockRepository.GenerateMock<ISyncAdvancedSessionOperation>(); advanced.Stub(x => x.NumberOfRequests).Return(10); var session = MockRepository.GenerateMock<IDocumentSession>(); session.Stub(x => x.Advanced).Return(advanced); session.Advanced.NumberOfRequests.ShouldEqual(10); var request = new OwinHttpRequest(); request.FullUrl("http://something/somethingelse"); request.HttpMethod("GET"); var currentPrincipal = new GenericPrincipal(new GenericIdentity("bob"), new string[0]); Thread.CurrentPrincipal = currentPrincipal; theMessage = DisposeRavenSessionMessage.For(session); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); theHttpRequest.FullUrl("http://server/fubu"); var registry = new FubuRegistry(); registry.Actions.IncludeType <OneController>(); registry.Actions.IncludeType <TwoController>(); registry.Actions.IncludeType <QueryStringTestController>(); registry.Actions.IncludeType <OnlyOneActionController>(); graph = BehaviorGraph.BuildFrom(registry); var urlResolver = new ChainUrlResolver(theHttpRequest); urls = new UrlRegistry(new ChainResolutionCache(graph), urlResolver, theHttpRequest); }
public HttpRequestSummary(ChainExecutionLog log) : this() { var request = new OwinHttpRequest(log.Request); var response = new OwinHttpResponse(log.Request); id = log.Id.ToString(); time = log.Time.ToHttpDateString(); url = request.RawUrl(); method = request.HttpMethod(); status = response.StatusCode; description = response.StatusDescription; if (status == 302) { // TODO -- write a helper for location description = response.HeaderValueFor(HttpResponseHeaders.Location).SingleOrDefault(); } contentType = response.ContentType(); duration = log.ExecutionTime; }
protected override void beforeEach() { theArguments = new ServiceArguments(); theEncoding = MockFor <IHttpContentEncoding>(); theAcceptedEncoding = "gzip, deflate, sdch"; theEncoding.Stub(x => x.MatchingEncoding).Return(ContentEncoding.GZip); MockFor <IHttpContentEncoders>().Stub(x => x.MatchFor(theAcceptedEncoding)).Return(theEncoding); var request = new OwinHttpRequest(); request.AppendHeader(HttpRequestHeaders.AcceptEncoding, theAcceptedEncoding); theArguments.Set(typeof(IHttpRequest), request); theArguments.Set(typeof(IHttpResponse), MockFor <IHttpResponse>()); ClassUnderTest.Filter(theArguments).ShouldBe(DoNext.Continue); }
public void SetUp() { container = new Container(x => { x.For <IFileSystem>().Use <FileSystem>(); x.For <IHttpResponse>().Use(new OwinHttpResponse()); x.For <ICurrentChain>().Use(new CurrentChain(null, null)); x.For <IHttpRequest>().Use(OwinHttpRequest.ForTesting()); x.For <IResourceHash>().Use(MockRepository.GenerateMock <IResourceHash>()); }); container.Configure(x => x.For <IContainerFacility>().Use <StructureMapContainerFacility>()); graph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType <TestController>(); // x.Route("/area/sub/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); // // x.Route("/area/sub2/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); // // x.Route("/area/sub3/{Name}/{Age}") // .Calls<TestController>(c => c.AnotherAction(null)); x.Models.ConvertUsing <ExampleConverter>().ConvertUsing <ExampleConverter2>(); x.Services(s => s.AddService <IActivator>(new StubActivator())); x.Services(s => s.AddService <IActivator>(new StubActivator())); x.Services(s => s.AddService <IActivator>(new StubActivator())); }); facility = new StructureMapContainerFacility(container); graph.As <IRegisterable>().Register(facility.Register); factory = facility.BuildFactory(graph); }
public void map_from_execution_log_happy_path() { var log = new ChainExecutionLog(); log.Request.Add(OwinConstants.ResponseStatusCodeKey, 200); log.Request.ResponseHeaders().Add(HttpResponseHeaders.ContentType, new []{"text/plain"}); var request = new OwinHttpRequest(log.Request); request.HttpMethod("POST"); request.FullUrl("http://server/foo"); log.MarkFinished(); var summary = new HttpRequestSummary(log); summary.id.ShouldBe(log.Id.ToString()); summary.time.ShouldBe(log.Time.ToHttpDateString()); summary.url.ShouldBe("/foo"); summary.method.ShouldBe("POST"); summary.status.ShouldBe(200); summary.contentType.ShouldBe("text/plain"); summary.duration.ShouldBe(log.ExecutionTime); }
public void SetUp() { var advanced = MockRepository.GenerateMock <ISyncAdvancedSessionOperation>(); advanced.Stub(x => x.NumberOfRequests).Return(10); var session = MockRepository.GenerateMock <IDocumentSession>(); session.Stub(x => x.Advanced).Return(advanced); session.Advanced.NumberOfRequests.ShouldBe(10); var request = new OwinHttpRequest(); request.FullUrl("http://something/somethingelse"); request.HttpMethod("GET"); var currentPrincipal = new GenericPrincipal(new GenericIdentity("bob"), new string[0]); Thread.CurrentPrincipal = currentPrincipal; theMessage = DisposeRavenSessionMessage.For(session); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); theHttpRequest.FullUrl("http://server/fubu"); var registry = new FubuRegistry(); registry.Actions.IncludeType<OneController>(); registry.Actions.IncludeType<TwoController>(); registry.Actions.IncludeType<QueryStringTestController>(); registry.Actions.IncludeType<OnlyOneActionController>(); registry.Configure(x => { x.TypeResolver.AddStrategy<UrlModelForwarder>(); }); //registry.Routes.HomeIs<DefaultModel>(); graph = BehaviorGraph.BuildFrom(registry); var resolver = graph.Services.DefaultServiceFor<ITypeResolver>().Value; var urlResolver = new ChainUrlResolver(theHttpRequest); urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver)resolver, graph), urlResolver, new JQueryUrlTemplate(), theHttpRequest); }
public OwinServiceArguments(RouteData routeData, IDictionary<string, object> environment) { var httpRequest = new OwinHttpRequest(environment); var httpContextBase = new OwinHttpContext(environment); Set(environment); Set<HttpContextBase>(httpContextBase); Set(routeData); Set<IHttpRequest>(httpRequest); Set<IHttpResponse>(new OwinHttpResponse(environment)); Set(new OwinContext(environment)); var log = environment.Log(); if (log != null) { Set(log); } }
public void SetUp() { theRequest = new OwinHttpRequest(); theSource = new HeaderValueSource(theRequest); }
public void SetUp() { theRequest = new OwinHttpRequest(); }
public SendExpression(OwinHttpRequest request) { _request = request; }
public void SetUp() { theRequest = OwinHttpRequest.ForTesting(); theCookies = new Core.Http.Cookies.Cookies(theRequest); }