public void Context()
        {
            WhenCalling <IOwinResponse>(x => x.WriteAsync(Arg <string> .Is.Anything))
            .Return(null)
            .Callback <string>(s =>
            {
                script = s;
                return(true);
            });

            WhenCalling <ITypeFinder>(x => x.ListEventTypes()).Return(new[] { typeof(NoMembersEvent), typeof(MembersEvent) });
            Mock <IHeaderDictionary>();

            WhenAccessing <IOwinRequest, IHeaderDictionary>(x => x.Headers).Return(Get <IHeaderDictionary>());
            WhenAccessing <IOwinResponse, IHeaderDictionary>(x => x.Headers).Return(Get <IHeaderDictionary>());

            WhenAccessing <IOwinContext, IOwinResponse>(x => x.Response).Return(Get <IOwinResponse>());
            WhenAccessing <IOwinContext, IOwinRequest>(x => x.Request).Return(Get <IOwinRequest>());


            var eventScriptMiddleware = new EventScriptMiddleware <TestEventBase>(null);

            eventScriptMiddleware.Invoke(Get <IOwinContext>());
            //script = context.Response.Output.ToString();
        }
        public void Context()
        {
            WhenCalling<IOwinResponse>(x => x.WriteAsync(Arg<string>.Is.Anything))
                .Return(null)
                .Callback<string>(s =>
                    {
                        script = s;
                        return true;
                    });

            WhenCalling<ITypeFinder>(x => x.ListEventTypes()).Return(new[] {typeof (NoMembersEvent), typeof (MembersEvent)});
            Mock<IHeaderDictionary>();
            
            WhenAccessing<IOwinRequest, IHeaderDictionary>(x => x.Headers).Return(Get<IHeaderDictionary>());
            WhenAccessing<IOwinResponse, IHeaderDictionary>(x => x.Headers).Return(Get<IHeaderDictionary>());

            WhenAccessing<IOwinContext, IOwinResponse>(x => x.Response).Return(Get<IOwinResponse>());
            WhenAccessing<IOwinContext, IOwinRequest>(x => x.Request).Return(Get<IOwinRequest>());
            

            var eventScriptMiddleware = new EventScriptMiddleware<TestEventBase>(null);

            eventScriptMiddleware.Invoke(Get<IOwinContext>());
            //script = context.Response.Output.ToString();
        }
        public void Setup(DateTime?cached = null)
        {
            var context = new DefaultHttpContext();
            var mem     = new MemoryStream();

            context.Response.Body = mem;
            if (cached.HasValue)
            {
                context.Request.Headers["If-Modified-Since"] = cached.Value.StripMilliseconds().ToString("r");
            }

            var eventScriptMiddleware = new EventScriptMiddleware(null);

            eventScriptMiddleware.Invoke(context, Get <IEventTypeFinder>());
            Script = Encoding.UTF8.GetString(mem.ToArray());
            DateTime.TryParse(context.Response.Headers["Last-Modified"], out LastModified);
            LastModified = LastModified.ToUniversalTime();
        }
Пример #4
0
        public void Context()
        {
            var eventScriptMiddleware = new EventScriptMiddleware(null);

            eventScriptMiddleware.Invoke(Get <HttpContext>(), Get <IEventTypeFinder>());
        }